Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1736

QQmlApplicationEngine::load() no longer works with string argument

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 6.2.0, 6.2.1
    • PySide
    • None
    • Windows
    • 3efe0b3e66 (pyside/pyside-setup/dev) 3577886cc8 (pyside/pyside-setup/6.2) 3577886cc8 (pyside/tqtc-pyside-setup/6.2) 3efe0b3e66 (pyside/tqtc-pyside-setup/dev) 3efe0b3e66 (pyside/tqtc-pyside-setup/tqtc/dev) 3577886cc8 (pyside/pyside-setup/6.2.3)

    Description

      It worked under 6.1.3 and is not working since 6.2.0

      Workaround is to cast it directly with "QUrl().fromLocalFile"

      Attached a working example

      import sys
      import os
      from PySide6.QtCore import QUrl
      
      from PySide6.QtGui import QGuiApplication, QIcon
      from PySide6.QtQml import QQmlApplicationEngine
      
      if __name__ == "__main__":
          app = QGuiApplication([])
          app.setApplicationName("Test")
      
          engine = QQmlApplicationEngine()
      
          path = os.path.dirname( os.path.realpath(__file__) )
      
          qml_file_path = os.path.join(path, "qml","main2.qml")
          qml_file_url = QUrl.fromLocalFile( qml_file_path )
          engine.load( qml_file_url )
      
          if not engine.rootObjects():
              sys.exit(-1)
      
          sys.exit( app.exec() )
      
      

      Errors are something like

      p usingmodel.py
      c:%5Cdev%5Cpyside%5Cpyside-setup%5Cexamples%5Cdeclarative%5Cusingmodel%5Cview.qml: Network error
      

      Attachments

        1. main.py
          0.6 kB
        2. pyside1736_diag.diff
          1 kB
        3. pyside1736_url_ct.py
          0.7 kB
        4. pyside1736.zip
          1 kB

        Issue Links

          For Gerrit Dashboard: PYSIDE-1736
          # Subject Branch Project Status CR V

          Activity

            People

              kleint Friedemann Kleint
              rusticus Markus Bauer
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes