Get QtGraphs with XYModelMapper working
-
You need to set the
seriesproperty of your XYModelMapper. -
@GrecKo Thanks! I also found that out. But the lineseries must also have a color different from backround and there must be explicit axes. My working qml file is now:
import QtQuick import QtGraphs import graphsexample 1.0 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") GraphsView { id: graphsView antialiasing: true anchors.fill: parent //legend.visible: false ValueAxis { id: axisX min: 0 max: 10 // Anpassen an Ihre Daten titleText: "X-Achse" } ValueAxis { id: axisY min: 0 max: 10 // Anpassen an Ihre Daten titleText: "Y-Achse" } LineSeries { id: lineSeries color: "#00ff00" joinStyle: Qt.RoundJoin XYModelMapper { model: Graphsmodel series: lineSeries xSection: 0 ySection: 1 } axisX: axisX axisY: axisY } } }Also this Connections don't work. It must be Graphsmodel with captal letter in XYModelMapper:
Connections{ id: graphsmodel target: Graphsmodel } -
@GrecKo I have an additional question, because it is important for my project:
How can I update the axes in the following sense:ValueAxis { id: axisX min: Graphsmodel.returnXmin() max: Graphsmodel.returnXmax() titleText: "X-Achse" }Even with fixed starting values this is not working for me.
-
Try to expose the xMin and xMan as properties with a NOTIFY signal instead to make the min and max binding automatically update. I guess it is currently calling returnXmin/max initially when the model is maybe empty, and then it isn't called again.
-
Try to expose the xMin and xMan as properties with a NOTIFY signal instead to make the min and max binding automatically update. I guess it is currently calling returnXmin/max initially when the model is maybe empty, and then it isn't called again.
-
@Igor23 add the following in your model
Q_PROPERTY( float minX MEMBER m_fMinX NOTIFY minXChanged )
define m_fMinX and signal minXChanged in your model.Do the same for maxX.
and
ValueAxis { id: axisX min: Graphsmodel.minX max: Graphsmodel.maxX titleText: "X-Achse" } -
And I have a second additional question: is there maximum number of points I can draw via Lineseries and XYModelMapper? It seems to me as there is a limit by Qt framework ...
-
The LineSeries type has a count property that returns the number of data points in the series so I would venture that the maximum int value is the limit but I wouldn't try to show that many data point anyway because it does not make sense. If anything, I would rather allow the user to zoom in/out of sections of a LineSeries if they need more precise data.
-
@Igor23 add the following in your model
Q_PROPERTY( float minX MEMBER m_fMinX NOTIFY minXChanged )
define m_fMinX and signal minXChanged in your model.Do the same for maxX.
and
ValueAxis { id: axisX min: Graphsmodel.minX max: Graphsmodel.maxX titleText: "X-Achse" } -
I Igor23 has marked this topic as solved
-
I Igor23 has marked this topic as unsolved