pyqtgraphpyqt6

Adding pyqtgraph to PyQt6


So I am making a GUI using Pyqt6 and want to add graphs inside the Gui with other data, SO when I try adding the graph i get the error bellow:

call: addWidget(self, QWidget): argument 1 has unexpected type 'PlotWidget' addWidget(self, QWidget, int, int, alignment: Qt.AlignmentFlag = Qt.Alignment()): argument 1 has unexpected type 'PlotWidget' addWidget(self, QWidget, int, int, int, int, alignment: Qt.AlignmentFlag = Qt.Alignment()): argument 1 has unexpected type 'PlotWidget'

The code I have

    self.plt=pyqtgraph.PlotWidget()
    self.plt.plot([1,2,3,4,5],[1,2,3,4,5])
    grid.addWidget(self.plt, 6, 1, 3, 3)
    self.setLayout(grid)  #up I have grid=QGridLayout()

Solution

  • I was trying to reproduce Your issue for a while.
    I succeeded after I install PyQt5 and PyQt6 together in the same environment.

    As @musicamante pointed out, it's important to first import PyQt6 and ONLY after that pyqtgraph. Otherwise QT_LIB is not set properly and only guesses PyQt version from already installed packages in the environment.