0
未示出我有一個網格佈局PyQt的情節在網格
類Ui_MainWindow(對象)的主窗口:
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1850, 1700) # width, height
self.gl_main = QGridLayout(self.centralwidget)
w = ChartWidget(self)
self.gl_main.addWidget(w, 4, 0, 1, 1)
class ChartWidget(QWidget):
def __init__(self, parent=None):
super(ChartWidget, self).__init__(parent)
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.axes = self.figure.add_subplot(111)
self.axes.hold(False)
self.axes.plot(range(10), range(10), 'b')
self.canvas.draw()
self.show()
的chartwidget不被添加到GridLayout的,雖然。我可以簡單地看到它在屏幕上閃爍,但它不見了。我該如何附加它?