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. How to plot python x,y data in QtCharts

How to plot python x,y data in QtCharts

Scheduled Pinned Locked Moved Unsolved Qt for Python
qt for pythonpythonpyside
1 Posts 1 Posters 306 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.
  • W Offline
    W Offline
    Witc
    wrote on last edited by Witc
    #1

    I want to plot data (from python) in QML Qt chart. Normally for passing data from python to QML I use Signals and Slot. e.g. for passing int variable I create signal in python class
    signalInt = Signal(int, arguments=['value']) and later I call signalInt.emit(23)

    then catching the value in QML
    In QML file:

    Connections {
                target: backend
    
                function onSignalInt(value) {
                    tempVal = value;
                }
    

    It works...

    My questions:

    1. How to pass array or list (I need pass X and Y values to plot) from python to QML
    2. How to tell qtCharts to plot my X Y data?

    I have these but it obviously does not work

    Connections {
                target: backend
    
                function onSignaXYData(dataX,dataY) {
                    plotDataX = dataX;
                    plotDataY = dataY;
                }
    
     ChartView {
                    title: "Line"
                    anchors.fill: parent
                    antialiasing: true
    
                    ValueAxis{
                        id: axisX
                        min: 0
                        max: 200
                    }
    
                    ValueAxis{
                        id: axisY
                        min: 0
                        max: 150
                    }
    
    
                    LineSeries {
                        id: lineSeries1
                        name: "data"
                        axisX: axisX
                        axisY: axisY
                        XYSeries: plotDataX, plotDataY
                    }
                }
    

    Thank you very much!

    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