pyqt4 eric4 generated gui custom dialog open

Detlev Offenbach detlev at die-offenbachs.de
Tue Dec 15 12:56:40 EST 2009


rewonka wrote:

> Hi,
> 
> I've made a little application with mainwindow and one dialog
> (something like input dialog).
> I can't open the input dialog from my mainwindow
> 
> I tried to open the dialog with a button, here is a code:
>     @pyqtSignature("")
>     def on_BtnAdd_clicked(self):
>         """
>         Open input dialog for some data input
>         """
>         Dialog = QDialog()
>         ui = DlgAdd()
>         ui.setupUi(Dialog)
>         Dialog.show()
> 
> and if I clicked the button , it's like the dialog open and disappear.

That is caused by the Python garbage collector removing your objects when 
the method is left. In order to keep the dialog, you must assign it to 
some class members. Alternatively you may replace "Dialog.show()" with 
Dialog.exec_() to get a modal dialog.

Detlev

> I searched a lot and found , that i need something to connect, but i
> didn't found how (exactly source code). On the dialog i have two
> button (OK,Cancel).
> As i saw the generated code for pyqt has line like this:
>     QtCore.QMetaObject.connectSlotsByName(MainWindow)
> I think that's mean i don't need to connect, if i have the function
> for it,but I don't know how to write??
> 
> Thank for Help,
> Rewonka

-- 
Detlev Offenbach
detlev at die-offenbachs.de



More information about the Python-list mailing list