Results 1 to 3 of 3

Thread: Please! Need help JUST TO START implementing Python code into QT designed forms

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Please! Need help JUST TO START implementing Python code into QT designed forms

    Your main program adapted with markers showing where:
    Qt Code:
    1. from PyQt4.QtCore import *
    2. from PyQt4.QtGui import *
    3.  
    4. from t_transfer import Ui_Dialog # <<<< Import the class the Designer built
    5.  
    6. class DoItNow(QDialog):
    7. def __init__(self, parent=None):
    8. super(DoItNow, self).__init__(parent)
    9.  
    10. self.ui = Ui_Dialog() # <<<< Creates an instance of the class the Designer built
    11. self.ui.setupUi(self) # <<<< Finishes initialising it
    12.  
    13. @pyqtSignature("")
    14. def on_pushButton_clicked(self):
    15. a = self.ui.lineEdit.text() # <<<< self.ui refers to the ui object just like in C++
    16. self.ui.label.setText(a)
    17.  
    18. if __name__ == "__main__":
    19. import sys
    20. app = QApplication(sys.argv)
    21. form = DoItNow() #<<<< your class is called DoItNow not Dialog
    22. form.show()
    23. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 

    There are other ways to do the UI incorporation: http://www.riverbankcomputing.co.uk/.../designer.html

  2. The following user says thank you to ChrisW67 for this useful post:

    OPG_79 (2nd August 2012)

  3. #2
    Join Date
    Jul 2012
    Posts
    2
    Thanks
    1
    Qt products
    Platforms
    Windows

    Default Re: Please! Need help JUST TO START implementing Python code into QT designed forms

    It works! Thanks a lot ChrisW67. Now I can continue

Similar Threads

  1. convert c++ class to python code
    By alrawab in forum Qt Programming
    Replies: 8
    Last Post: 25th June 2012, 08:43
  2. access the source code of the .ui forms
    By Hamza217 in forum Newbie
    Replies: 3
    Last Post: 4th May 2011, 06:33
  3. execute python in the Qt code
    By gorka_sm in forum Newbie
    Replies: 0
    Last Post: 28th April 2010, 15:04
  4. Embedding python code in Qt
    By lixo1 in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2010, 18:02
  5. Objective C, Python and Ruby code with C++ Qt application
    By Berberis in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2008, 12:40

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
  •  
Qt is a trademark of The Qt Company.