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
Forum Updated to NodeBB v4.3 + New Features

Error is not an attribute of QQuickView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 168 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.
  • Y Offline
    Y Offline
    YvesB
    wrote on 6 May 2025, 20:48 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

    J S 2 Replies Last reply 6 May 2025, 21:43
    0
    • Y YvesB
      6 May 2025, 20:48

      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

      J Offline
      J Offline
      JonB
      wrote on 6 May 2025, 21:43 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
        6 May 2025, 20:48

        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

        S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 7 May 2025, 06:18 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 on 7 May 2025, 17:13 last edited by
          #4

          Thanks guys, this was that.

          1 Reply Last reply
          0
          • Y YvesB has marked this topic as solved on 7 May 2025, 17:13

          3/4

          7 May 2025, 06:18

          • Login

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