[Qt-interest] Resizing problem with own scrollbar

Ole Streicher ole-usenet-spam at gmx.net
Thu May 28 14:00:21 CEST 2009


Hi again,

(Is there something wrong with my mails? I get almost no response on them)

I have a window that consists of a main (diagram) widget, and a
scrollbar. The main widget (a matplotlib FigureCanvas) takes some
milliseconds to update and redraw.

When I resize the window, sometimes the scrollbar is not displayed
correctly. It is either drawn at the wrong place (if I change the window
height), or with the wrong size (if I change the window width)

I started to debugging it a bit by adding debug output to the
moveEvent()/resizeEvent() functions. I seems that the resizeEvents
(resp. moveEvents) come out of order. The following comes when one
resizes the window width:

figure resize to QSize(803, 474) <-- first event
figure resize to QSize(879, 474) <-- second event
scroll resize to QSize(879, 15)  <-- second event (wrong!!)
scroll resize to QSize(803, 15)  <-- first event

My interpretation of this is:
- the FigureCanvas gets the first resize event and repaints itself (*)
- during the repaint it gets the second resize event
- since it is already in the repaint process, the second request
  is ignored (or queued) and returns immediately
- this leads to the processing of the second resize for the scrollbar
- after the first repaint (*) is finished, the first resize of the 
  scrollbar is started

Who should be blamed for that? Is it
- Qt since they dont distribute the events in the order of occurrence to
  the layout childs?
- or FigureCanvas since it returns from the secons call while the first
  one is not finished yet?

How can I workaround this?

Best regards,

Ole




More information about the Qt-interest-old mailing list