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. QSurfaceDataProxy not working in QML
Qt 6.11 is out! See what's new in the release blog

QSurfaceDataProxy not working in QML

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 713 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.
  • S Offline
    S Offline
    sauropodbob
    wrote on last edited by
    #1

    Hi

    I am trying to use QSurfaceDataProxy from python in QML but I keep getting this error "Unable to assign [undefined] to QSurfaceDataProxy*".

    Can you help with what could be the cause? Thank you

    Here are the code snippets

    python snippet

    class Surface2(QObject):
        name_changed = Signal(QSurfaceDataProxy)
        simulator_nameChanged = Signal(str)
    
    
        def __init__(self, parent=None):
            QObject.__init__(self, parent)
            
            self.surfaceproxy = QSurfaceDataProxy()
            # self.surfaceseries = QSurface3DSeries(self.surfaceproxy)
            self.create_data()
            self.test_name = "blue"
    
        @Property(str, notify=simulator_nameChanged)
        def color_name(self):
            return self.test_name
    
        def create_data(self):
            x = [1,2,3]
            y = [3,4,5]
            z = [6,7,8]
    
            data_arr = []
            for i, item in enumerate(x):
                row = [QSurfaceDataItem(QVector3D(x[i], y[i], z[i]))]
                print(row[0].x())
                data_arr.append(row)
            self.surfaceproxy.resetArray(data_arr)
            print(self.surfaceproxy.rowCount())
            return self.surfaceproxy
    
        @Property(QSurfaceDataProxy, notify=name_changed)
        def output(self):
            return self.surfaceproxy
    
    engine.rootContext().setContextProperty("surfaceDataModel", surface_model)
    

    qml snippet

            Surface3D {
                id: surfacePlot
                width: parent.width
                height: parent.height
                theme: Theme3D {
                        type: Theme3D.ThemeStoneMoss
                        font.family: "STCaiyun"
                        backgroundColor: surfaceDataModel.color_name
                        font.pointSize: 35
                        colorStyle: Theme3D.ColorStyleRangeGradient
    
    
                Surface3DSeries {
                    itemLabelFormat: "Pop density at (@xLabel N, @zLabel E): @yLabel"
                    dataProxy: surfaceDataModel.output
    
                }
            }
    
    1 Reply Last reply
    0
    • F Offline
      F Offline
      friedemannkleint
      wrote on last edited by
      #2

      Have you tried exposing the proxy to QML using decorators as done in the file system example https://doc.qt.io/qtforpython-6/examples/example_quickcontrols_filesystemexplorer.html ?

      S 1 Reply Last reply
      0
      • F friedemannkleint

        Have you tried exposing the proxy to QML using decorators as done in the file system example https://doc.qt.io/qtforpython-6/examples/example_quickcontrols_filesystemexplorer.html ?

        S Offline
        S Offline
        sauropodbob
        wrote on last edited by
        #3

        @friedemannkleint
        Thank you. Will try it

        1 Reply Last reply
        0

        • Login

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