[Kde-games-devel] Extra resize events from KXmlGuiWindow
Parker Coates
parker.coates at gmail.com
Tue Mar 31 02:49:21 CEST 2009
On Mon, Mar 30, 2009 at 7:45 PM, Ian Wadham wrote:
> On Tue, 31 Mar 2009 1:36:38 am Parker Coates wrote:
>> This morning on IRC, David pointed me to his workaround code in the
>> Konqueror unit tests [1]. I applied it to KPat and it does, indeed
>> skip the resize event related to the delayed menubar insertion.
>
> Can you explain (on the KDE Games list) how the code at
>
> http://lxr.kde.org/source/KDE/kdebase/apps/konqueror/src/tests/konqviewmgrtest.cpp#057
>
> addresses the problem and which bit of code does so? I had a look at it. It
> seems to precipitate "pending" events, but I cannot see how it avoids them.
Simply call that function on your mainwindow before you show it. As
for how it works, I'm only guessing, but I think:
- Qt only does certain layout actions once the widget in question is visible.
- The code checks all subwidgets for the Qt::WA_PendingResizeEvent
flag indicating that it is waiting for a resize.
- It then constructs a resize event and makes the widget visible so
that the resize can occur.
- It then processes those the pending events and starts again.
- If it it can't find anything waiting to be resized, it hides
everything again, so that Qt isn't surprised when it tries to show it
later on.
So essentially the resize events are all processed synchronously
inside this function, so that you can move on with your life. This
works nicely for KPat because I can easily call this function before
actually creating the view or the scene [1]. I now realise this might
not be as cleanly applicable to other games.
Parker
[1] See the bottom of kpat/main.cpp in trunk.
More information about the kde-games-devel
mailing list