pyqtgraph - 将 pyqtgraph 添加到 PyQt6

标签 pyqtgraph 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:

调用: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/

相关文章:

python - 在 pyqtgraph 中的 x 轴上显示字符串值

python - pyQTGraph设置轴值(FFT)

python - 使用pyqtgraph使用外部数据进行绘图

python - 如何使用 webEngineContextLog 禁用 QWebEngineView 日志记录?

python - QSqlRelationalDelegate 显示foreign_key - 相关记录的id,而不是组合框中的名称/值

python - finplot 作为布局中的小部件

python - pyqtgraph/查科/guiqwt : Fast scrolling timetrace demo

python - 如何从循环中创建的组合框获取反馈

python - 设置缩放 QGraphicsItem 的变换点