Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Error is not an attribute of QQuickView

Error is not an attribute of QQuickView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 81 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.
  • Y Offline
    Y Offline
    YvesB
    wrote last edited by
    #1

    Hello,
    I'm migrating a Python script from Qt5 to Qt6.
    But I'm facing to an error where I don't find a solution.

     view = QQuickView()
        view.setResizeMode(QQuickView.ResizeMode.SizeRootObjectToView)
        view.setTitle(app.translate("app", "Welcome"))
    ...
        current_path = os.path.abspath(os.path.dirname(__file__))
        qml_file = os.path.join(current_path, "mw-ui.qml")
        view.setSource(QUrl.fromLocalFile(qml_file))
        if view.status() == QQuickView.Error:
            for error in view.errors():
                print(error.description())
            sys.exit(-1)
        view.show()
    

    I get:

        if view.status() == QQuickView.Error:
    AttributeError: type object 'QQuickView' has no attribute 'Error'. Did you mean: 'errors'?
    

    However, this is what is exposed in https://doc-snapshots.qt.io/qtforpython-6.5/examples/example_qml_signals_pytoqml1.html

    I use pyqt6 6.4

    JonBJ SGaistS 2 Replies Last reply
    0
    • Y YvesB

      Hello,
      I'm migrating a Python script from Qt5 to Qt6.
      But I'm facing to an error where I don't find a solution.

       view = QQuickView()
          view.setResizeMode(QQuickView.ResizeMode.SizeRootObjectToView)
          view.setTitle(app.translate("app", "Welcome"))
      ...
          current_path = os.path.abspath(os.path.dirname(__file__))
          qml_file = os.path.join(current_path, "mw-ui.qml")
          view.setSource(QUrl.fromLocalFile(qml_file))
          if view.status() == QQuickView.Error:
              for error in view.errors():
                  print(error.description())
              sys.exit(-1)
          view.show()
      

      I get:

          if view.status() == QQuickView.Error:
      AttributeError: type object 'QQuickView' has no attribute 'Error'. Did you mean: 'errors'?
      

      However, this is what is exposed in https://doc-snapshots.qt.io/qtforpython-6.5/examples/example_qml_signals_pytoqml1.html

      I use pyqt6 6.4

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by
      #2

      @YvesB
      You quote a reference to PySide documentation yet say you use PyQt. They are different. And I suspect in this area where I think the issue will be in the changes which came in Qt enum specifiers, which did indeed change from Qt5 to Qt6 in Python.

      Error is a Status. Although I am not sure exactly what you will need to change it to, but something like QQuickView.Status.Error will be required now I think in Python. And may vary from PySide to PyQt.

      1 Reply Last reply
      2
      • Y YvesB

        Hello,
        I'm migrating a Python script from Qt5 to Qt6.
        But I'm facing to an error where I don't find a solution.

         view = QQuickView()
            view.setResizeMode(QQuickView.ResizeMode.SizeRootObjectToView)
            view.setTitle(app.translate("app", "Welcome"))
        ...
            current_path = os.path.abspath(os.path.dirname(__file__))
            qml_file = os.path.join(current_path, "mw-ui.qml")
            view.setSource(QUrl.fromLocalFile(qml_file))
            if view.status() == QQuickView.Error:
                for error in view.errors():
                    print(error.description())
                sys.exit(-1)
            view.show()
        

        I get:

            if view.status() == QQuickView.Error:
        AttributeError: type object 'QQuickView' has no attribute 'Error'. Did you mean: 'errors'?
        

        However, this is what is exposed in https://doc-snapshots.qt.io/qtforpython-6.5/examples/example_qml_signals_pytoqml1.html

        I use pyqt6 6.4

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote last edited by
        #3

        @YvesB hi,

        @JonB is correct. Enumerations are now fully qualified.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          YvesB
          wrote last edited by
          #4

          Thanks guys, this was that.

          1 Reply Last reply
          0
          • Y YvesB has marked this topic as solved

          • Login

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