Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-132790

Unexpected behaviour of QScatterSeries for selectedPoints, replace and deselectAllPoints

    XMLWordPrintable

Details

    • macOS

    Description

      Refer this example:

      from PyQt6 import QtWidgets
      from PyQt6 import QtCore
      from PyQt6 import QtGui
      from PyQt6 import QtCharts
      from PyQt6.QtCore import Qt
      
      def create_chart(points, xrange, yrange):
          chart=QtCharts.QChart()
          chart_view=QtCharts.QChartView(chart)
          xaxis = QtCharts.QValueAxis()
          xaxis.setTickAnchor(1)
          chart.addAxis(xaxis, Qt.AlignmentFlag.AlignBottom)
          xaxis.setRange(xrange[0], xrange[1])
      
          yaxis = QtCharts.QValueAxis()
          yaxis.setTickInterval(1)
          chart.addAxis(yaxis, Qt.AlignmentFlag.AlignLeft)
          yaxis.setRange(yrange[0], yrange[1])
      
          scatter_series=QtCharts.QScatterSeries()
          scatter_series.setSelectedColor(QtGui.QColor("red"))
          chart.addSeries(scatter_series)
          scatter_series.attachAxis(xaxis)
          scatter_series.attachAxis(yaxis)
          for point in points:
              scatter_series.append(point[0], point[1])
          print(scatter_series.selectedPoints())  # []
          scatter_series.selectPoints([4,5])
          print(scatter_series.selectedPoints())  # [4, 5]
          scatter_series.replace([QtCore.QPointF(1, -20), QtCore.QPointF(2, -22), QtCore.QPointF(3, -20), QtCore.QPointF(4, -22), QtCore.QPointF(5, -20)])
          print(scatter_series.selectedPoints())  # [4, 5]
          scatter_series.deselectAllPoints()
          print(scatter_series.selectedPoints())  # [5]
          return chart_view
      
      app = QtWidgets.QApplication([])
      
      ch1 = create_chart([[1, -26.957], [2, -23.022], [3, -26.957], [4, -23.022], [5, -26.957], [6, -23.022]], [0, 7], [-30, -18])
      ch1.show()
      
      app.exec() 

      Scatter series had 6 points.
      Selected indices 4 and 5
      Replaced the series with 5 points
      selectedPoints still returns 4 and 5 (series doesn't have any point at index 5)
      After deselectAllPoints, selectedPoints returns 5 (series doesn't have any point at index 5)

      Is this expected behaviour?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            e0348803 Miikka Heikkinen
            chetangarg Chetan Garg
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes