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

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

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. Shilpa
    Replies:
    1
    Views:
    6,266
    Anubhav Jain
    Mar 22, 2006
  2. hg
    Replies:
    25
    Views:
    926
    Sean Schertell
    Jan 26, 2007
  3. Glen
    Replies:
    2
    Views:
    714
  4. ff

    Custom PyQt4 Slots

    ff, Aug 11, 2008, in forum: Python
    Replies:
    3
    Views:
    488
  5. ff

    Custom PyQt4 TableWidget

    ff, Aug 27, 2008, in forum: Python
    Replies:
    4
    Views:
    441
  6. Florian Wollenschein

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

    Florian Wollenschein, May 4, 2009, in forum: Python
    Replies:
    2
    Views:
    2,571
    Florian Wollenschein
    May 5, 2009
  7. wgw
    Replies:
    1
    Views:
    624
  8. Andrew
    Replies:
    3
    Views:
    2,692
    David Boddie
    Feb 6, 2010
Loading...