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:
调用:addWidget(self, QWidget): 参数 1 具有意外类型 'PlotWidget' ' addWidget(self, QWidget, int, int, int, int, alignment: Qt.AlignmentFlag = Qt.Alignment()): argument 1 has unexpected type 'PlotWidget'
我的代码
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()
最佳答案
有一段时间我一直在尝试重现您的问题。
我在同一个环境下一起安装PyQt5和PyQt6成功了。
正如@musicamante 所指出的,重要的是首先导入 PyQt6 并且仅在该 pyqtgraph 之后。 否则QT_LIB设置不正确,只能从环境中已安装的包中猜测 PyQt 版本。
关于pyqtgraph - 将 pyqtgraph 添加到 PyQt6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70887458/