PDA

View Full Version : atomicy in gui draws



elcuco
6th July 2006, 20:53
Hi,

I have faced a problem on my mdi library, which I cannot fully understand. The problem is that when you move the focus from one tab to another, and both contain the same type of toolbars, the toolbars flick a lot (see how it's done on KDE for example).

What happens when you move the focus to a tab is:


QToolBar* qmdiActionGroup::updateToolBar( QToolBar *toolbar )
{
if (!toolbar)
toolbar = new QToolBar( name );

toolbar->clear();
int i = 0;
foreach( QObject *o, actionGroupItems )
{
QAction *a = qobject_cast<QAction*> (o);
if (a)
toolbar->addAction( a );
else
{
QWidget *w = qobject_cast<QWidget*> (o);
if (w)
{
toolbar->addWidget( w );
w->setVisible(true);
}
}

i++;
}

if (actionGroupItems.count() == 0)
toolbar->hide();
else
toolbar->show();

return toolbar;
}


As you see, the toolbar will be cleared and populated by the same icons (but different QActions). I tried solving this by adding a toolbar->setUpdatesEnabled() but still I see the flicks. I also tried to lock up the main window, and I still see the flicker.

Does anyone know some good trick that can help me?

For details about qmdilib see:
http://www.qtcentre.org/forum/f-qt-software-16/t-announce-qmdilib-001-2602.html

gfunk
6th July 2006, 21:41
I found that some layouts in my ui would still do some weird painting even with updates disabled, until I setVisible(false) on the layouts in addition. You might want to step through the paint source code, if possible.

elcuco
7th July 2006, 20:02
Thanks,

Using setUpdatesEnabled(false) and then hide() does help a lot.

I am not marking this a "solved" as there are some issues yet. It helps a lot, but I still have problems.