因为我没有得到一个答案这个问题,我试着用PyQt的解决它。 显然,这不是那么容易,当QScrollArea参与...
我写了一个小测试,基本上做什么我要找的,但它没有显示滚动区域和它里面的情节如我所料:
from PyQt4 import QtCore, QtGui
import os,sys
#import matplotlib
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
from matplotlib.figure import Figure
qapp = QtGui.QApplication(sys.argv)
qwidget = QtGui.QWidget()
qwidget.setGeometry(QtCore.QRect(0, 0, 500, 500))
qlayout = QtGui.QHBoxLayout(qwidget)
qwidget.setLayout(qlayout)
qscroll = QtGui.QScrollArea(qwidget)
qscroll.setGeometry(QtCore.QRect(0, 0, 500, 500))
qscroll.setFrameStyle(QtGui.QFrame.NoFrame)
qlayout.addWidget(qscroll)
qscrollContents = QtGui.QWidget()
qscrollLayout = QtGui.QVBoxLayout(qscrollContents)
qscrollLayout.setGeometry(QtCore.QRect(0, 0, 1000, 1000))
qscroll.setWidget(qscrollContents)
qscroll.setWidgetResizable(True)
for i in xrange(5):
qfigWidget = QtGui.QWidget(qscrollContents)
fig = Figure((5.0, 4.0), dpi=100)
canvas = FigureCanvas(fig)
canvas.setParent(qfigWidget)
toolbar = NavigationToolbar(canvas, qfigWidget)
axes = fig.add_subplot(111)
axes.plot([1,2,3,4])
qscrollLayout.addWidget(qfigWidget)
qscrollContents.setLayout(qscrollLayout)
qwidget.show()
exit(qapp.exec_())
任何人都可以解释为什么它不工作?