Strange resize behaviour for qt backend

Hi,

could anyone reproduce this problem and/or has a solution for it? Is
there anything wrong with my code?

Best regards

Ole

Ole Streicher <ole-usenet-spam@...361...> writes:

···

Hi Darren,

Darren Dale <dsdale24@...287...> writes:

I am really busy with other things, and can't offer suggestions unless
you post a short, simple, standalone script that demonstrates the
problem.

Sure:
--------------------------------8<-----------------------------------------
import random
import sys

from PyQt4 import QtGui, QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure,SubplotParams

class DiagramWidget(QtGui.QWidget):
    def __init__(self, parent):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout(self)
        self.setLayout(layout)
        self.diagram = InnerDiagramWidget(self)
        self.scrollbar = QtGui.QScrollBar(QtCore.Qt.Horizontal, self)
        layout.addWidget(self.diagram)
        layout.addWidget(self.scrollbar)

    def resizeEvent(self, event):
        print 'figure resize to', event.size()
        QtGui.QWidget.resizeEvent(self, event)

class InnerDiagramWidget(FigureCanvas):
    def __init__(self, parent):
        fig = Figure()
        self.axes = fig.add_subplot(111)
        range = xrange(10000)
        l = [ random.randint(-5, 5) for i in range ]
        self.axes.plot(range, l, drawstyle='steps')
        FigureCanvas.__init__(self, fig)
        self.setParent(parent)
        FigureCanvas.setSizePolicy(self,
                                   QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

    def resizeEvent(self, event):
        print 'scroll resize to', event.size()
        FigureCanvas.resizeEvent(self, event)

a = QtGui.QApplication(sys.argv)
w = QtGui.QMainWindow()
w.setCentralWidget(DiagramWidget(w))
w.show()
a.exec_()
--------------------------------8<-----------------------------------------

To see the problem undisturbed, you may remove the "resizeEvent()"
functions.

Best regards

Ole