0
我正在嘗試將Pyqtgraph嵌入到PyQt4 GraphicsView小部件中。我收到以下代碼的錯誤:我究竟做錯了什麼?錯誤將Pyqtgraph嵌入到PyQt4 GraphicsView中
#imports
from PyQt4 import QtGui
from PyQt4 import QtCore
import ui_test #Gui File
import sys
import pyqtgraph as pg
class Gui(QtGui.QMainWindow, ui_test.Ui_MainWindow, pg):
vb = pg.ViewBox()
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self) # This is defined in ui_pumptest.py file automatically
self.graphicsView.setCentralItem(self.vb) #set central item to be graph
def main():
app = QtGui.QApplication(sys.argv) # A new instance of QApplication
form = Gui() # We set the form to be our ExampleApp (design)
form.show() # Show the form
app.exec_() # and execute the. app
if __name__ == '__main__': # if we're running file directly and not importing it
main() # run the main function
的錯誤是:
QWidget: Must construct a QApplication before a QPaintDevice