Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. NotImplementedError: pure virtual method 'QAbstractCameraController.moveCamera' not implemented.
Forum Updated to NodeBB v4.3 + New Features

NotImplementedError: pure virtual method 'QAbstractCameraController.moveCamera' not implemented.

Scheduled Pinned Locked Moved Solved Qt for Python
6 Posts 2 Posters 547 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.
  • M Offline
    M Offline
    manuelo
    wrote on last edited by
    #1

    Hi all,

    I'm using PySide6 on Python 3.11 on Mac and Linux. I'm trying to create a Trackball to Qt3D in Python based on this https://github.com/cjmdaixi/Qt3DTrackball. So I'm creating the TrackballCameraController inheriting from QAbstractCameraController.moveCamera. Here a simple sample:

    import sys
    from typing import Optional
    
    from PySide6.Qt3DCore import Qt3DCore
    from PySide6.Qt3DExtras import Qt3DExtras
    from PySide6.Qt3DInput import Qt3DInput
    from PySide6.Qt3DRender import Qt3DRender
    from PySide6.QtCore import QObject, QPoint, QSize, QUrl
    from PySide6.QtGui import QColor, QGuiApplication, QVector3D, qRgb
    from PySide6.QtWidgets import QApplication
    
    
    class TrackballCameraController(Qt3DExtras.QAbstractCameraController):
        def __init__(self, parent: Optional[Qt3DCore.QNode]=None):
            super().__init__(parent)
    
        def moveCamera(self, state: Qt3DExtras.QAbstractCameraController.InputState, dt: float):
            print("moveCamera")
    
    
    def create_sphere(parent: Qt3DCore.QEntity) -> Qt3DCore.QEntity:
        # Create sphere mesh
        sphere_mesh = Qt3DExtras.QSphereMesh(parent)
        sphere_mesh.setRadius(3.0)
    
        # Create sphere material
        sphere_material = Qt3DExtras.QPhongMaterial(parent)
        # sphere_material.setDiffuse(QColor(255, 0, 0))
        #
        sphere_transform = Qt3DCore.QTransform(parent)
        # sphere_transform.setTranslation(QVector3D(-3, -3, -3))
    
        # Create sphere entity
        sphere_entity = Qt3DCore.QEntity(parent)
        sphere_entity.addComponent(sphere_mesh)
        sphere_entity.addComponent(sphere_transform)
        sphere_entity.addComponent(sphere_material)
    
        return sphere_entity
    
    
    if __name__ == "__main__":
        # Create application
        app = QGuiApplication(sys.argv)
    
        # Create window
        window = Qt3DExtras.Qt3DWindow()
        window.setTitle("Sphere Example")
    
        # Create root entity
        root_entity = Qt3DCore.QEntity()
    
        # Create sphere entity
        sphere_entity = create_sphere(root_entity)
    
        print(sphere_entity.components())
    
        camera = window.camera()
        camera.setPosition(QVector3D(0.0, 0.0, 40.0))
        camera.setViewCenter(QVector3D(0.0, 0.0, 0.0))
        camera.lens().setPerspectiveProjection(45.0, 16.0 / 9.0, 0.1, 1000)
    
        camera_controller = TrackballCameraController(root_entity)
        camera_controller.setCamera(camera)
    
        # Set root entity as the root of the scene
        window.setRootEntity(root_entity)
        window.defaultFrameGraph().setClearColor(QColor(0, 0, 255))
        # Show window
        window.show()
    
        # Run application
        sys.exit(app.exec())
    

    But I'm getting this error:

    Qt3D.Renderer.RHI.Backend: Initializing RHI with Metal backend
    Traceback (most recent call last):
      File "/Users/thiago/Sources/qt3d_experiments/draw_sphere.py", line 73, in <module>
        sys.exit(app.exec())
                 ^^^^^^^^^^
    NotImplementedError: pure virtual method 'QAbstractCameraController.moveCamera' not implemented.
    

    But I implemented moveCamera in my child class... Is it correct to inherit from QAbstractCameraController? Do I need to do more things to inherit from QAbstractCameraController?

    SGaistS 1 Reply Last reply
    0
    • M manuelo

      Tested on Windows 11, Python 3.11, PySide6 6.4.2 and this error happens:

      Qt3D.Renderer.RHI.Backend: Initializing RHI with DirectX backend
      Qt3D.Renderer.RHI.Backend: Can't create pipeline, incomplete SwapChain and no default Render Target
      

      If I comment the part that creates the TrackballCameraController this problem doesn't happen.

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #5

      @manuelo It's a now know issue, see PYSIDE-2255.

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

      M 1 Reply Last reply
      1
      • M manuelo

        Hi all,

        I'm using PySide6 on Python 3.11 on Mac and Linux. I'm trying to create a Trackball to Qt3D in Python based on this https://github.com/cjmdaixi/Qt3DTrackball. So I'm creating the TrackballCameraController inheriting from QAbstractCameraController.moveCamera. Here a simple sample:

        import sys
        from typing import Optional
        
        from PySide6.Qt3DCore import Qt3DCore
        from PySide6.Qt3DExtras import Qt3DExtras
        from PySide6.Qt3DInput import Qt3DInput
        from PySide6.Qt3DRender import Qt3DRender
        from PySide6.QtCore import QObject, QPoint, QSize, QUrl
        from PySide6.QtGui import QColor, QGuiApplication, QVector3D, qRgb
        from PySide6.QtWidgets import QApplication
        
        
        class TrackballCameraController(Qt3DExtras.QAbstractCameraController):
            def __init__(self, parent: Optional[Qt3DCore.QNode]=None):
                super().__init__(parent)
        
            def moveCamera(self, state: Qt3DExtras.QAbstractCameraController.InputState, dt: float):
                print("moveCamera")
        
        
        def create_sphere(parent: Qt3DCore.QEntity) -> Qt3DCore.QEntity:
            # Create sphere mesh
            sphere_mesh = Qt3DExtras.QSphereMesh(parent)
            sphere_mesh.setRadius(3.0)
        
            # Create sphere material
            sphere_material = Qt3DExtras.QPhongMaterial(parent)
            # sphere_material.setDiffuse(QColor(255, 0, 0))
            #
            sphere_transform = Qt3DCore.QTransform(parent)
            # sphere_transform.setTranslation(QVector3D(-3, -3, -3))
        
            # Create sphere entity
            sphere_entity = Qt3DCore.QEntity(parent)
            sphere_entity.addComponent(sphere_mesh)
            sphere_entity.addComponent(sphere_transform)
            sphere_entity.addComponent(sphere_material)
        
            return sphere_entity
        
        
        if __name__ == "__main__":
            # Create application
            app = QGuiApplication(sys.argv)
        
            # Create window
            window = Qt3DExtras.Qt3DWindow()
            window.setTitle("Sphere Example")
        
            # Create root entity
            root_entity = Qt3DCore.QEntity()
        
            # Create sphere entity
            sphere_entity = create_sphere(root_entity)
        
            print(sphere_entity.components())
        
            camera = window.camera()
            camera.setPosition(QVector3D(0.0, 0.0, 40.0))
            camera.setViewCenter(QVector3D(0.0, 0.0, 0.0))
            camera.lens().setPerspectiveProjection(45.0, 16.0 / 9.0, 0.1, 1000)
        
            camera_controller = TrackballCameraController(root_entity)
            camera_controller.setCamera(camera)
        
            # Set root entity as the root of the scene
            window.setRootEntity(root_entity)
            window.defaultFrameGraph().setClearColor(QColor(0, 0, 255))
            # Show window
            window.show()
        
            # Run application
            sys.exit(app.exec())
        

        But I'm getting this error:

        Qt3D.Renderer.RHI.Backend: Initializing RHI with Metal backend
        Traceback (most recent call last):
          File "/Users/thiago/Sources/qt3d_experiments/draw_sphere.py", line 73, in <module>
            sys.exit(app.exec())
                     ^^^^^^^^^^
        NotImplementedError: pure virtual method 'QAbstractCameraController.moveCamera' not implemented.
        

        But I implemented moveCamera in my child class... Is it correct to inherit from QAbstractCameraController? Do I need to do more things to inherit from QAbstractCameraController?

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi and welcome to devnet,

        Which version of PySide6 are you using ?

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

        M 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Which version of PySide6 are you using ?

          M Offline
          M Offline
          manuelo
          wrote on last edited by
          #3

          Hi @SGaist and thanks!

          I'm using PySide6 6.4.2 installed from Pypi. If I run the sample code I posted in Linux the sphere doesn't show and when I close the window the process doesn't stop, I have to kill it. If I comment the part that creates the TrackballCameraController this problem doesn't happen.

          M 1 Reply Last reply
          0
          • M manuelo

            Hi @SGaist and thanks!

            I'm using PySide6 6.4.2 installed from Pypi. If I run the sample code I posted in Linux the sphere doesn't show and when I close the window the process doesn't stop, I have to kill it. If I comment the part that creates the TrackballCameraController this problem doesn't happen.

            M Offline
            M Offline
            manuelo
            wrote on last edited by
            #4

            Tested on Windows 11, Python 3.11, PySide6 6.4.2 and this error happens:

            Qt3D.Renderer.RHI.Backend: Initializing RHI with DirectX backend
            Qt3D.Renderer.RHI.Backend: Can't create pipeline, incomplete SwapChain and no default Render Target
            

            If I comment the part that creates the TrackballCameraController this problem doesn't happen.

            SGaistS 1 Reply Last reply
            0
            • M manuelo

              Tested on Windows 11, Python 3.11, PySide6 6.4.2 and this error happens:

              Qt3D.Renderer.RHI.Backend: Initializing RHI with DirectX backend
              Qt3D.Renderer.RHI.Backend: Can't create pipeline, incomplete SwapChain and no default Render Target
              

              If I comment the part that creates the TrackballCameraController this problem doesn't happen.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @manuelo It's a now know issue, see PYSIDE-2255.

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

              M 1 Reply Last reply
              1
              • SGaistS SGaist

                @manuelo It's a now know issue, see PYSIDE-2255.

                M Offline
                M Offline
                manuelo
                wrote on last edited by
                #6

                Fixed on the 6.4.3.

                1 Reply Last reply
                0
                • M manuelo has marked this topic as solved on

                • Login

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