Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. PyQt5.4. No window shown
Forum Updated to NodeBB v4.3 + New Features

PyQt5.4. No window shown

Scheduled Pinned Locked Moved Language Bindings
pyqt5
2 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hongquan
    wrote on last edited by
    #1

    Hi. I try a minimal PyQt5.4 app:

    https://bitbucket.org/snippets/hongquan/Kond

    When I run

    python3 run.y
    

    no window shows. What did I do wrong?

    1 Reply Last reply
    0
    • jazzycamelJ Offline
      jazzycamelJ Offline
      jazzycamel
      wrote on last edited by
      #2

      Did you get any errors when you try to run it?

      The following works perfectly for me on Mac OSX 10.8, Python3.4, Qt5.4:

      test.qml

      import QtQuick 2.2
      import QtQuick.Controls 1.1
      
      ApplicationWindow{
        width: 400
        height: 300
        visible: true
        title: qsTr("Hello")
        Label{
          text: qsTr("Hello")
          anchors.centerIn: parent
        }
      }
      

      run.py

      from PyQt5.QtCore import *
      from PyQt5.QtGui import *
      from PyQt5.QtQml import *
      from sys import argv, exit
      
      def createApplication():
          app=QGuiApplication(argv)
          engine=QQmlApplicationEngine(app)
          engine.load(QUrl("test.qml"))
          return app    
      
      if __name__=="__main__":
          app=createApplication()
          exit(app.exec_())
      

      To execute:

      $ python run.py
      

      For the avoidance of doubt:

      1. All my code samples (C++ or Python) are tested before posting
      2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved