PDA

View Full Version : flicker when hide() QPushButton with stylesheet (background-image)



doitux
7th October 2007, 09:06
Hi @all

Can you please tell me how to avoid the flickering which you can see on this
video:

http://www.pokerth.net/hideButtonFlicker.mpeg

The green "raise" botton was set with:
----------------------------------------------------------------------------------------------------------------
pushButton_BetRaise->setStyleSheet("QPushButton { border:none;
background-image: url(" + myAppDataPath
+"gfx/gui/table/default/playeraction_03.png); "+ font2String +" font-size:
11px; font-weight: bold; color: #F0F0F0; }");
------------------------------------------------------------------------------------------------------------------

myAppDataPath could be "/home/user/PokerTH-0.6/data/" so the url value would
be: background-image:
url(/home/user/PokerTH-0.6/data/gfx/gui/table/default/playeraction_03.png);

Please note that it reads the gfx from an external directory NOT from an
resource collection files (.qrc). May be that is the problem?

The grey square (which is the default-look of the button in designer) flicker
happends when doing:
----------------------------------------------------------------------------------------------------------------
pushButton_BetRaise->hide();
spinBox_set->show();
----------------------------------------------------------------------------------------------------------------

The screencapture video grabs it not very accurate. When doing the code above
the first time after application start the grey square appears around one
whole second until it *disappears and spinBox_set is show.

The next time doing the pushButton_BetRaise->hide(); spinBox_set->show(); it
works nearly without flickering.

Sometimes ago i used the resource collection files to store the gfx files.
There wasn't any flickering problems. But i also changed to qt-4.3.1 during
remove the use of qrc so i'am cannot guess which is the problem qt-4.3.1
or "not-qrc".

May be there is a totaly different problem you can tell me about and may be
you can help me how to fix it.

best regards
Felix Hammer
_______________________________________
http://www.pokerth.net

jacek
7th October 2007, 23:02
Please note that it reads the gfx from an external directory NOT from an resource collection files (.qrc). May be that is the problem?
Yes, it could be. It takes a bit of time to read the data from disk, while if you use resources, the data is already in memory.


But i also changed to qt-4.3.1 during
remove the use of qrc so i'am cannot guess which is the problem qt-4.3.1
or "not-qrc".
You could create a .qrc file with that problematic image to see whether the flicker will go away.

Since the flicker doesn't appear, if you show the widget for the second time, the solution would be to make Qt cache the image before you use it. QPixmapCache might help you with this.