On Dec 17, 2007 3:56 PM, Andreas Pakulat <<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On 17.12.07 15:08:23, duncan duncan wrote:<br>> On Dec 17, 2007 3:00 PM, duncan duncan <<a href="mailto:duncan73@gmail.com">duncan73@gmail.com</a>> wrote:<br>><br>> > Hello.
<br>> ><br>> > In my application (a QApplication), as central widget I have two<br>> > QListWidget.<br>> ><br>> > When I double click on an item of a list widget, I want to show a dialog<br>> > with some detail data for the item
<br>> ><br>> ><br>> > This is the relevant code, the dialog is designed using Qt-Designer and<br>> > windowModality is Qt::NonModal<br>> ><br>> > ---<br>> > ItemDlg = QtGui.QDialog
()<br>> > ItemDlgGui = Ui_D_item_detail()<br>> > ItemDlgGui.setupUi(ItemDlg)<br>> ><br>> > ItemDlg.show()<br>> ><br>> > #ItemDlg.exec_()<br>> > ---<br>> ><br>> > If I use the
ItemDlg.exec_() line, all work correctly, but the dialog is<br>> > modal, so I cannot work on the main window.<br>> ><br>> > Since I want a modeless dialog, I try to use ItemDlg.show() but now the<br>> > dialog show itself and then close immediatly.
<br>> ><br>> > Any hints ?<br>> ><br>><br>> It seems that by mistake I resolve the problem.<br>><br>> It just need to call the .show() AND the .exec_() function.<br><br></div></div>No you don't. You actually want to make sure the instance doesn't get
<br>deleted once the function that creates it ends. Thats why its closed<br>immediately when you only use show(). When the function ends, there's no<br>refernece to the dialog anymore, because ItemDlg is a local variable,
<br>thus the dialog is garbage collected.<br></blockquote><div><br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>Do something like
self.itemdialog = QtGui.QDialog() instead of the first<br>line above.<br></blockquote><div><br>Actually I modified all the structure, so these lines of codes are in
the __init__ function of a derived class (not important I suppose).<br>
<br>
The whole point of the problem is that I want (and I need) to be able
to open the dialog (the display a set of editable data), look at it,
modify some field, then eventually open another dialog which display
some diffente data (basically the data are record of a db table)<br>
<br>
If in the __init__ funciont I put the code you suggest, without the call to .exec_(), the dialog close immediatly. I suppose that this happen because self is not a pointer to the application, but a pointer to the dialog class.
<br><br>For now it work as I expect, I will do further investigation as soon as the code will stabilize a little (and all the feature are implemented)<br><br>Thanks anyway<br>bye<br>Gianluca<br><br><br></div></div>