pyqt4 eric4 generated gui custom dialog open

R

rewonka

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.
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
 
D

Detlev Offenbach

rewonka said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top