Skip to content

Overriding QCPGraph::selectTest breaks the selection #6

Description

@naquad

Versions

Python: 3.10.8
PyQt5: 5.15.7
PyQt5-sip: 12.11.0
QCustomPlot_PyQt5: 2.1.1.1

Description

I've tried to subclass QCPGraph to add extra handling for selection but found that overriding selectTest() method breaks the selection completely.

Test case

#!/usr/bin/env python3

from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPen, QColor
from PyQt5.QtWidgets import QMainWindow, QApplication
import QCustomPlot_PyQt5 as qcp

class CustomGraph(qcp.QCPGraph):
    def selectTest(self, *args): # I've also tried with the signature, no luck
        return super().selectTest(*args)

app = QApplication([])

win = QMainWindow()
win.setWindowTitle('Test')
win.setMinimumSize(1024, 768)

plot = qcp.QCustomPlot()
plot.setInteraction(qcp.QCP.iSelectPlottables, True)

data = list(range(1, 100))
graph = CustomGraph(plot.xAxis, plot.yAxis)
graph.setPen(QPen(QColor(Qt.red), 10))
graph.setData(data, data)

win.setCentralWidget(plot)
win.show()
app.exec_()

Expected behavior

Clicks select the plottable.

Actual behavior

No selection happens.

A note: while the click selection is broken, the rect selection is working somehow.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions