nnguyenquy
nnguyenquy

Reputation: 1

I'm getting an error: QGraphicsView(parent: QWidget = None): argument 1 has unexpected type 'MainWindow'

I'm trying to run my Gui but I got this error:

TypeError: arguments did not match any overloaded call:
QGraphicsView(parent: QWidget = None): argument 1 has unexpected type 'MainWindow'
QGraphicsView(QGraphicsScene, parent: QWidget = None): argument 1 has unexpected type 'MainWindow'

First, my Gui worked pretty well but then when I added an inherent class from another file I got that error

I get my error at there:

    self.graphWidget = PlotWidget(self)
    # self.setCentralWidget(self.graphWidget)
    self.graphWidget.setGeometry(640, 50, 530, 500)

    # Add Background color to black
    self.graphWidget.setBackground("k")
    # Add Title
    self.graphWidget.setTitle("Filtered PPG Signal", color="g", size="15pt")
    # Add Axis Labels
    styles = {"color": "#0f0", "font-size": "15px"}  # red #f00 green #0f0
    self.graphWidget.setLabel("left", "Amplitude", **styles)
    self.graphWidget.setLabel("bottom", "Datapoint", **styles)
    # Add legend
    self.graphWidget.addLegend()
    # Add grid
    self.graphWidget.showGrid(x=True, y=True)
    # Set Range
    self.graphWidget.setXRange(0, 10, padding=1)
    self.graphWidget.setYRange(25, 50, padding=1)

I added that class:

class MainWindow(MainWindow_1):
def __init__(self):
    super().__init__()
    self.scan_button_hrv.clicked.connect(self.clear_graph)
    self.scan_button_hrv.clicked.connect(self.draw)

def clear_graph(self):
    self.graphWidget.clear()

def draw(self):
    results, data_green = PPG_sensor()
    self.data = data_green.tolist()

    self.x = list(range(1000))
    self.y = self.data[0:1000]
    self.index = 1000

    pen = mkPen(color=(250, 0, 0))
    self.data_line = self.graphWidget.plot(self.x, self.y, pen=pen)

    self.timer = QtCore.QTimer()
    self.timer.setInterval(10)
    self.timer.timeout.connect(self.update_data)
    self.start()

def update_data(self):
    self.x = self.x[1:]
    self.x.append(self.x[-1] + 1)

    self.y = self.y[1:]
    self.y.append(self.data[self.index])
    self.index += 1

    self.data_line.setData(self.x, self.y)

I don't know why PlotWidget(self) gets error why before I added an inherent class it worked. Is there anyway that I can resolve my error? Thank you very much.

Upvotes: 0

Views: 27

Answers (0)

Related Questions