PDA

View Full Version : [qt5] repainting qwidget



zodiac
23rd July 2012, 19:43
Hello.


void dUpload::show( Qt::WindowFlags flags )
{
//setWindowFlags( flags );

setAttribute(Qt::WA_NoSystemBackground, true);

show();
}

After call setAttribute function from this code my qwidget doesn't repaint (i.e. I see artefacts from child widgets), but when I resize that widget, then it repaints.

Is it bug in qt5 or I do something wrong?

OS: win7 + msvs 2010.

wysota
24th July 2012, 07:35
What does your paint event look like?

zodiac
24th July 2012, 08:48
Firstly (when I created this topic) I didn't use paintEvent.
Now it is:

void dUpload::paintEvent( QPaintEvent *event )
{
QPainter p(this);
p.setCompositionMode(QPainter::CompositionMode_Cle ar);
p.fillRect(0, 0, width(), height(), Qt::BrushStyle::SolidPattern);
}
and this resolved my problem (artefacts goes away). But I think it's just hack :)

wysota
24th July 2012, 10:42
So why are you using the NoSystemBackground attribute?

zodiac
24th July 2012, 16:40
So why are you using the NoSystemBackground attribute?
I need to make my widget glass-styled (windows 7), and for that I use this code:

void dUpload::show( Qt::WindowFlags flags )
{
setWindowFlags( flags );

//setAttribute(Qt::WA_NoSystemBackground, true); // 1
setAttribute(Qt::WA_TranslucentBackground, true); // 2

if ( QtWin::isCompositionEnabled() )
QtWin::extendFrameIntoClientArea( this );

show();
}
1 and 2 are equal, i.e. widget will be glassed, but not repainted.

UPD: screenshot when it doesn't repaint:
http://i.stack.imgur.com/1qLYP.png

wysota
25th July 2012, 08:00
They are definitely not equal. (1) is wrong, (2) is correct.

zodiac
25th July 2012, 09:49
They are definitely not equal. (1) is wrong, (2) is correct.

But widget also doesn't automatically repaint when (2) is activated.

wysota
25th July 2012, 10:35
It does repaint. It just doesn't paint its background.

zodiac
25th July 2012, 11:39
It does repaint. It just doesn't paint its background.

Do you mean this is normal behaviour? But in qt4 I didn't see any artefacts.

wysota
25th July 2012, 11:53
Qt5 is still pre-beta, so I would expect glitches.

zodiac
25th July 2012, 14:34
Qt5 is still pre-beta, so I would expect glitches.
Ok, I thought such bugs can't be in beta (http://releases.qt-project.org/qt5.0/beta-snapshots/).

wysota
25th July 2012, 15:10
It's not beta, it's pre-beta. Besides I don't know if what you experience is a glitch or not. I'm just saying glitches are expected.