[Development] QBackingStore and alien widgets

Rafael Roquetto rafael.roquetto at kdab.com
Thu May 2 23:11:42 CEST 2013


Hello,

While debugging the QNX platform plugin, I found out that when QWidget::winId()
is called on a non-toplevel widget, it will still use its parents
QBackingStore for rendering. Is this really the intended behavior?

This behavior is caused because ultimately, because
QWidgetPrivate::maybeBackingStore() will call QWidget::window(), which returns
the window of the toplevel widget, even if the caller widget has its own
native window, despite being a child widget, as illustrated below:

QWidget *QWidget::window() const
{
    QWidget *w = (QWidget *)this;
    QWidget *p = w->parentWidget();
    while (!w->isWindow() && p) {
        w = p;
        p = p->parentWidget();
    }
    return w;
}

If this is not the intended behavior, but rather a bug, checking for
Qt::WA_NativeWindow on the while condition should fix the problem, although I
do not have enough knowledge to be sure this wouldn't break other platforms.

Context: On QNX, every window needs to have its own buffer, even child windows. In this
context, I would expect the widget on which windId() has been called to be
able to draw to its own backing store, instead of its parent's.


Any thoughts?

Regards,
Rafael

-- 
Rafael Roquetto | rafael.roquetto at kdab.com | Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3721 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130502/78adc518/attachment.bin>


More information about the Development mailing list