Results 1 to 3 of 3

Thread: [SOLVED]How to connect different UI files

  1. #1
    Join Date
    Sep 2015
    Posts
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default [SOLVED]How to connect different UI files

    image : Attachment 11368

    Im trying to connect different Qt Dialogs using PyQt , but I can't figure out how to do that.
    In my example, "dialog_inserir.ui" will be main window, so when I click "say hello !" button, the second window will appear.
    How to do that in Python Qt code ?

    The code im trying :

    Qt Code:
    1. import dialog_inserir as di # the first window of image
    2. import hello as hl # the "hello world" window
    3. import sys
    4. from PyQt4 import QtGui, QtCore
    5.  
    6.  
    7. class MainWindow(QtGui.QDialog):
    8. def __init__(self, parent=None):
    9. QtGui.QWidget.__init__(self, parent)
    10. self.ui = di.Ui_Dialog()
    11. self.ui.setupUi(self)
    12. QtCore.QObject.connect(self.ui.pushButtonSayHello, QtCore.SIGNAL('clicked()'), self.Hello)
    13.  
    14. def Hello(self):
    15. # ... what here ? ...
    16. pass
    17.  
    18. class HelloWindow(QtGui.QDialog):
    19. def __init__(self, parent=None):
    20. QtGui.QWidget.__init__(self, parent)
    21. self.helloui = hl.Ui_Dialog()
    22. self.helloui.setupUi(self)
    23.  
    24. if __name__ == "__main__":
    25. app = QtGui.QApplication(sys.argv)
    26. mywindow = MainWindow()
    27. mywindow.show()
    28. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    Last edited by chiruL; 12th September 2015 at 21:58. Reason: solved

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to connect different UI files

    probably something like this
    Qt Code:
    1. def Hello(self):
    2. helloWindow = HelloWindow(self)
    3. helloWindow.show()
    4. pass
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Sep 2015
    Posts
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to connect different UI files

    Oh thanks, I was missing the second 'self' arg !

Similar Threads

  1. Connect Window with MainWindow different Files.
    By Mauricio in forum Qt Programming
    Replies: 10
    Last Post: 13th July 2014, 21:59
  2. Replies: 1
    Last Post: 27th June 2014, 17:29
  3. How to connect functions of QML files?
    By Yonetici in forum Qt Quick
    Replies: 2
    Last Post: 20th July 2012, 20:47
  4. Replies: 1
    Last Post: 28th January 2012, 13:35
  5. Replies: 2
    Last Post: 9th May 2011, 11:38

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.