Integrating Python with QT



  • Hi All
    Can some one guide me with example Python can be integrated in QT and how we can show the same



  • Have you seen PyQt or PySide?

    The Language Bindings category is a better place for this topic.


  • Lifetime Qt Champion

    Moved.

    Hi,

    What do you mean by integrate python with Qt ?

    Run a python script through the C++ runtime or as @jeremy_k suggests, use Qt to build a python application ?



  • Any example will be helpful


  • Qt Champions 2016

    @Qt-Enthusiast

    PyQt example

    #! /usr/bin/env python
    # -*- coding: utf-8 -*-
    #
    # Here we provide the necessary imports.
    # The basic GUI widgets are located in QtGui module. 
    import sys
    from PyQt4.QtGui import QApplication, QWidget
    
    # Every PyQt4 application must create an application object.
    # The application object is located in the QtGui module.
    a = QApplication(sys.argv)
    
    # The QWidget widget is the base class of all user interface objects in PyQt4.
    # We provide the default constructor for QWidget. The default constructor has no parent.
    # A widget with no parent is called a window. 
    w = QWidget()
    
    w.resize(320, 240)  # The resize() method resizes the widget.
    w.setWindowTitle("Hello, World!")  # Here we set the title for our window.
    w.show()  # The show() method displays the widget on the screen.
    
    sys.exit(a.exec_())  # Finally, we enter the mainloop of the application.
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.