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. QDataVisualization

QDataVisualization

Scheduled Pinned Locked Moved Solved Qt for Python
7 Posts 2 Posters 670 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 SGaist
    #1

    Hi. I am new to Qt and PySide6. I want to understand how QDataVisualization in QML works. I found a sample code on one of the example pages and tried to run it on my local system.

    However, when I run the code, a window opens and immediately closes. This only happens with QDataVisualization. Can anyone advise what could be the reason for this? Thank you. The code is shown below

    import QtQuick 6
    import QtQuick.Controls 6
    import QtDataVisualization 1.14
    import QtCharts 2.14
    import QtQuick.Layouts 1.14
    import QtQuick.Window 2.14
    import "."
    
    ApplicationWindow {
        title: qsTr("Test")
        width: 1280
        height: 720
        visible: true
        Item {
            width: 640
            height: 480
    
            Bars3D {
                width: parent.width
                height: parent.height
    
                Bar3DSeries {
                    itemLabelFormat: "@colLabel, @rowLabel: @valueLabel"
    
                    ItemModelBarDataProxy {
                        itemModel: dataModel
                        // Mapping model roles to bar series rows, columns, and values.
                        rowRole: "year"
                        columnRole: "city"
                        valueRole: "expenses"
                    }
                }
            }
    
            ListModel {
                id: dataModel
                ListElement{ year: "2012"; city: "Oulu";     expenses: "4200"; }
                ListElement{ year: "2012"; city: "Rauma";    expenses: "2100"; }
                ListElement{ year: "2012"; city: "Helsinki"; expenses: "7040"; }
                ListElement{ year: "2012"; city: "Tampere";  expenses: "4330"; }
                ListElement{ year: "2013"; city: "Oulu";     expenses: "3960"; }
                ListElement{ year: "2013"; city: "Rauma";    expenses: "1990"; }
                ListElement{ year: "2013"; city: "Helsinki"; expenses: "7230"; }
                ListElement{ year: "2013"; city: "Tampere";  expenses: "4650"; }
            }
        }
    }
    
    SGaistS 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi and welcome to devnet,

      Can you also post the python script you use ?
      As well as the PySide6 version you installed and how you installed it.

      On a side note, please use coding tags for your code to make it properly readable (fixed it for you).

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

      @SGaist Hi. I am following up on my reply. Thank you

      SGaistS 1 Reply Last reply
      0
      • S sauropodbob

        Hi. I am new to Qt and PySide6. I want to understand how QDataVisualization in QML works. I found a sample code on one of the example pages and tried to run it on my local system.

        However, when I run the code, a window opens and immediately closes. This only happens with QDataVisualization. Can anyone advise what could be the reason for this? Thank you. The code is shown below

        import QtQuick 6
        import QtQuick.Controls 6
        import QtDataVisualization 1.14
        import QtCharts 2.14
        import QtQuick.Layouts 1.14
        import QtQuick.Window 2.14
        import "."
        
        ApplicationWindow {
            title: qsTr("Test")
            width: 1280
            height: 720
            visible: true
            Item {
                width: 640
                height: 480
        
                Bars3D {
                    width: parent.width
                    height: parent.height
        
                    Bar3DSeries {
                        itemLabelFormat: "@colLabel, @rowLabel: @valueLabel"
        
                        ItemModelBarDataProxy {
                            itemModel: dataModel
                            // Mapping model roles to bar series rows, columns, and values.
                            rowRole: "year"
                            columnRole: "city"
                            valueRole: "expenses"
                        }
                    }
                }
        
                ListModel {
                    id: dataModel
                    ListElement{ year: "2012"; city: "Oulu";     expenses: "4200"; }
                    ListElement{ year: "2012"; city: "Rauma";    expenses: "2100"; }
                    ListElement{ year: "2012"; city: "Helsinki"; expenses: "7040"; }
                    ListElement{ year: "2012"; city: "Tampere";  expenses: "4330"; }
                    ListElement{ year: "2013"; city: "Oulu";     expenses: "3960"; }
                    ListElement{ year: "2013"; city: "Rauma";    expenses: "1990"; }
                    ListElement{ year: "2013"; city: "Helsinki"; expenses: "7230"; }
                    ListElement{ year: "2013"; city: "Tampere";  expenses: "4650"; }
                }
            }
        }
        
        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi and welcome to devnet,

        Can you also post the python script you use ?
        As well as the PySide6 version you installed and how you installed it.

        On a side note, please use coding tags for your code to make it properly readable (fixed it for you).

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

        S 2 Replies Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          Can you also post the python script you use ?
          As well as the PySide6 version you installed and how you installed it.

          On a side note, please use coding tags for your code to make it properly readable (fixed it for you).

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

          @SGaist Thank you for your response. The PySide6 version is 6.5.0. I installed it using pip. This is the python script

          import sys
          import os
          from pathlib import Path
          
          from PySide6.QtGui import QGuiApplication
          from PySide6.QtWidgets import QApplication
          from PySide6.QtQml import QQmlApplicationEngine, QmlElement
          from PySide6 import QtDataVisualization
          from PySide6.QtCore import QObject, Signal, Slot
          
          
          QML_IMPORT_NAME = "io.qt.textproperties"
          QML_IMPORT_MAJOR_VERSION = 1
          
          
          class Details(QObject):
              def __init__(self):
                  super().__init__()
          
          
          app = QApplication(sys.argv)
          engine = QQmlApplicationEngine()
          
          # Get Context
          main = Details()
          engine.rootContext().setContextProperty("backend", main)
          
          
          qml_file = Path(__file__).parent / "test_features/testfeature.qml"
          engine.load(qml_file)
          
          if not engine.rootObjects():
              sys.exit(-1)
          
          sys.exit(app.exec())
          
          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi and welcome to devnet,

            Can you also post the python script you use ?
            As well as the PySide6 version you installed and how you installed it.

            On a side note, please use coding tags for your code to make it properly readable (fixed it for you).

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

            @SGaist Hi. I am following up on my reply. Thank you

            SGaistS 1 Reply Last reply
            0
            • S sauropodbob

              @SGaist Hi. I am following up on my reply. Thank you

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

              @sauropodbob what happens if you add os.environ["QSG_RHI_BACKEND"] = "opengl" before creating the app object ?

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

              S 1 Reply Last reply
              0
              • SGaistS SGaist

                @sauropodbob what happens if you add os.environ["QSG_RHI_BACKEND"] = "opengl" before creating the app object ?

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

                @SGaist Looks like it works now. Thank you

                SGaistS 1 Reply Last reply
                0
                • S sauropodbob

                  @SGaist Looks like it works now. Thank you

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

                  Since you have it working now please mark the thread as solved using the "Topic Tools" button or the three doted menu beside the answer you deem correct so that the other forum members may know a solution has been found.

                  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
                  • S sauropodbob has marked this topic as solved on
                  • S sauropodbob 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