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. Problem with creation order with QtGraphs using model via ItemModelBarDataProxy
Forum Updated to NodeBB v4.3 + New Features

Problem with creation order with QtGraphs using model via ItemModelBarDataProxy

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 120 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.
  • F Offline
    F Offline
    fantaz
    wrote last edited by
    #1

    Hi all,
    Basically, I get the "Series needs to be created to access data members" and a crash when I execute this code below.
    I get that the ListModel is created later than the proxy model`. I just don't get what is the "proper" way to handle this situation?
    What am I doing wrong?

    import QtQuick
    import QtQuick.Controls
    import QtGraphs
    ApplicationWindow {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
    
        ListModel {
            id: barModel
            ListElement { name: "Earth"; diameter: 12742 }
            ListElement { name: "Mars"; diameter: 6779 }
            ListElement { name: "Jupiter"; diameter: 139820 }
            ListElement { name: "Venus"; diameter: 12104 }
        }
        GraphsView {
            anchors.fill: parent
            anchors.margins: 16
            axisX: BarCategoryAxis {
                gridVisible: false
                subGridVisible: false
            }
            axisY: ValueAxis {
                min: 6000
                max: 150000
            }
            BarSeries {
                ItemModelBarDataProxy {
                    id: secondaryProxy
                    itemModel: barModel
                    rowRole: "name"
                    columnRole: "name"
                    valueRole: "diameter"
                }
                // BarSet {
                //     values: [12000, 7000, 140000, 12000]
                //     borderWidth: 2
                //     color: "#373F26"
                //     borderColor: "#DBEB00"
                // }
            }
        }
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi,

      After a quick look, ItemModelBarDataProxy is for Bars3D that you are not using.

      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
      • F Offline
        F Offline
        fantaz
        wrote last edited by
        #3

        Ooh, don't know how I missed that. So, what should I use?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by
          #4

          What exactly are you trying to achieve ?

          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

          • Login

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