setPointConfiguration does nothing
-
I am using Qt ver 6.2.8 (64-bit) in Windows 10 (latest). I have a QLineSeries that I am trying to implement a way for the user to select a point with the mouse, and have that point highlighted with a larger symbol, and possible label the point. Though the code is pretty large at this point here are relevant snippets:
I have an over-loaded QChart classe that defines a QLineSeries:m_avgSeries= new QLineSeries(this); m_avgSeries->setName("Avg"); QPen avgCol(Qt::blue); m_avgSeries->setUseOpenGL(true); avgCol.setWidth(3); // m_avgSeries->setMarkerSize(8.0); m_avgSeries->setPointsVisible(true); m_avgSeries->setPen(avgCol); m_avgSeries->append(m_x, m_y); QObject::connect(m_avgSeries, SIGNAL(clicked(QPointF)), this, SLOT(handleAvgPtSelect(QPointF)));
I also define a pointConfiguration member variable:
// from header: QHash<QXYSeries::PointConfiguration, QVariant> ptconf; m_ptConf[QXYSeries::PointConfiguration::Color]= QColor(Qt::magenta); m_ptConf[QXYSeries::PointConfiguration::Size]= 8; m_ptConf[QXYSeries::PointConfiguration::LabelVisibility]= true;
Then in the slot handleAvgPtSelect I first find the index of the mouse-selected point (the m_avgSeries is pretty large at this point...), then try to highlight it with this code:
m_avgSeries->setPointConfiguration(index, m_ptConf); m_avgSeries->setPointSelected(index, true);
But this does nothing to the appearance on the graph. I have set breakpoints at various places in this code, and it is all getting hit at appropriate times. Any suggestions for what might be wrong are appreciated.
-
I am using Qt ver 6.2.8 (64-bit) in Windows 10 (latest). I have a QLineSeries that I am trying to implement a way for the user to select a point with the mouse, and have that point highlighted with a larger symbol, and possible label the point. Though the code is pretty large at this point here are relevant snippets:
I have an over-loaded QChart classe that defines a QLineSeries:m_avgSeries= new QLineSeries(this); m_avgSeries->setName("Avg"); QPen avgCol(Qt::blue); m_avgSeries->setUseOpenGL(true); avgCol.setWidth(3); // m_avgSeries->setMarkerSize(8.0); m_avgSeries->setPointsVisible(true); m_avgSeries->setPen(avgCol); m_avgSeries->append(m_x, m_y); QObject::connect(m_avgSeries, SIGNAL(clicked(QPointF)), this, SLOT(handleAvgPtSelect(QPointF)));
I also define a pointConfiguration member variable:
// from header: QHash<QXYSeries::PointConfiguration, QVariant> ptconf; m_ptConf[QXYSeries::PointConfiguration::Color]= QColor(Qt::magenta); m_ptConf[QXYSeries::PointConfiguration::Size]= 8; m_ptConf[QXYSeries::PointConfiguration::LabelVisibility]= true;
Then in the slot handleAvgPtSelect I first find the index of the mouse-selected point (the m_avgSeries is pretty large at this point...), then try to highlight it with this code:
m_avgSeries->setPointConfiguration(index, m_ptConf); m_avgSeries->setPointSelected(index, true);
But this does nothing to the appearance on the graph. I have set breakpoints at various places in this code, and it is all getting hit at appropriate times. Any suggestions for what might be wrong are appreciated.
-
@nekkceb
To me your code looks reasonable. I would spend the 5 minutes to set up a brand new project and just paste in the code from https://doc.qt.io/qt-6/qxyseries.html#setPointConfiguration. Does that work for you? -
@nekkceb
Then it's your job to find out how they differ! Check your value forindex
. Maybe when " (the m_avgSeries is pretty large at this point...)" it doesn't plot one point or it's hard tp see? Try calling thesetPointConfiguration()
on lots/every point in the series, is that visible? -
@nekkceb
To me your code looks reasonable. I would spend the 5 minutes to set up a brand new project and just paste in the code from https://doc.qt.io/qt-6/qxyseries.html#setPointConfiguration. Does that work for you?@JonB Well, it may be trying to use OpenGL, which I had turned on because other documentation suggested it would give me faster refreshes using large series. I juist turned that off:
m_series->setUseOpenGL(false) m_avgSeries->setUseOpenGL(false);
Not only do the PointConfigurations work, but I had also turned on pointsVisible for the series, and the points were not showing, only the lines.
-
@nekkceb
Then it's your job to find out how they differ! Check your value forindex
. Maybe when " (the m_avgSeries is pretty large at this point...)" it doesn't plot one point or it's hard tp see? Try calling thesetPointConfiguration()
on lots/every point in the series, is that visible?