Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unable to use QtQuick Controls 2 with Pyside 2
Forum Updated to NodeBB v4.3 + New Features

Unable to use QtQuick Controls 2 with Pyside 2

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 1.1k Views
  • 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.
  • M Offline
    M Offline
    mvanorder
    wrote on last edited by mvanorder
    #1

    I have set up:

    Python 3.5.3 virtual environment
    Compiled the Pyside 2 commit fafd92f428d51bdd56c90a73149c441773dd9155 (as the latest 2 commits were having issues with missing qrandomgenerator files).

    The compile was done with Qt 5.9.3, MSVC2015 x64, and cmake 3.10.1

    I'm trying to set this up to start using QML, and more specifically Material Style. However it seems that when I run my application, if the QML imports QtQuick.Controls 2.0 or later, engine.rootObjects() returns an empty list. I can import QtQuick.Controls versions 1.0 - 1.5. Did I miss something when compiling? or is there something wrong with my code?

    The code is as follows:

    Python

    import sys
    from PySide2 import QtGui
    from PySide2 import QtQml
    
    app = QtGui.QGuiApplication(sys.argv)
    engine = QtQml.QQmlApplicationEngine()
    ctx = engine.rootContext()
    ctx.setContextProperty("qmlapp", engine)
    engine.load('view.qml')
    win = engine.rootObjects()[0]
    win.show()
    sys.exit(app.exec_())
    

    QML

    import QtQuick 2.9
    import QtQuick.Controls 2.2
    
    ApplicationWindow {
    }
    

    I grabbed those version numbers from the documentation for Qt Quick Controls 2.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mvanorder
      wrote on last edited by
      #2

      I found the issue was I need QT bin in my path. Running the following corrected the issue:

      (venv35) C:\my\project\dir\>set PATH=C:\Qt\5.9.3\msvc2015_64\bin;%PATH%

      1 Reply Last reply
      1

      • Login

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