Qt4-preview-feedback Archive, January 2008
4.4.0-tp1: delayed repaint () invocation after access to winId ()
Message 1 in thread
In QMainWindow there is an eventFilter installed:
bool MainWindow::eventFilter (QObject * obj, QEvent * event)
{
switch (event->type ()) {
case QEvent::Show: {
((QWidget *)obj)->winId ();
break;
}
default:
break;
}
}
The access to 'winId' causes the affected widgets to use a native window.
The widget implements a drawing method that gets invoked by mouseMove, draws
into a QBitmap and finally calls repaint on the modified rect:
Widget::mouseMoveEvent () {
qDebug ("Widget::mouseMoveEvent");
... calc affected QRect
... draw QRect into QBitmap
repaint (QRect);
}
Widget::paintEvent (QPaintEvent * e) {
qDebug ("Widget::paintEvent");
QRect rect = e->region ().boundingRect ();
... draw QBitmap
}
If the above mentioned eventFilter is NOT set, the repaint is invoked
immediately - as specified in QWidget::repaint docs:
'Repaints the widget directly by calling paintEvent() immediately'
The debugging shows:
Widget::mouseMoveEvent
Widget::paintEvent
Widget::mouseMoveEvent
Widget::paintEvent
Widget::mouseMoveEvent
Widget::paintEvent
Now if the forementioned eventFilter is set, paintEvent () is called delayed,
the debugging now shows:
Widget::mouseMoveEvent
Widget::mouseMoveEvent
Widget::paintEvent
Widget::mouseMoveEvent
Widget::paintEvent
Widget::mouseMoveEvent
Widget::paintEvent
Widget::paintEvent
And subsequently the wrong (allready changed) QRect gets repainted.
The same behavior can be seen if QT_USE_NATIVE_WINDOWS=1 is set instead of
accessing the winId.
The behavior is identical on win and linux.
Seems like a bug to me!
Frank
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx