pyqt4 eric4 generated gui custom dialog open

Discussion in 'Python' started by rewonka, Dec 15, 2009.

  1. rewonka

    rewonka Guest

    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
     
    rewonka, Dec 15, 2009
    #1
    1. Advertising

  2. 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 Offenbach, Dec 15, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hg
    Replies:
    25
    Views:
    787
    Sean Schertell
    Jan 26, 2007
  2. Glen
    Replies:
    2
    Views:
    530
  3. Detlev Offenbach

    ANN: eric4 4.0.0 release

    Detlev Offenbach, Jun 3, 2007, in forum: Python
    Replies:
    0
    Views:
    272
    Detlev Offenbach
    Jun 3, 2007
  4. Florian Wollenschein

    Open a dialog from MainWindow - pyQT4 - Beginner :-)

    Florian Wollenschein, May 4, 2009, in forum: Python
    Replies:
    2
    Views:
    1,949
    Florian Wollenschein
    May 5, 2009
  5. wgw
    Replies:
    1
    Views:
    465
Loading...

Share This Page