[Interest] how exactly do you replace Qt4's QWidget::create(WId, ...) ?

René J.V. Bertin rjvbertin at gmail.com
Sun Aug 9 18:51:48 CEST 2020


Hi,

According to the documentation, where in Qt4/X11 one could create a "foreign" QWidget with QWidget::create(WId id, ...), in Qt5 one has to do something like

            externalWindow = QWindow::fromWinId(id);
            if (externalWindow) {
                externalParent = externalWindow->parent();
                theWidget = QWidget::createWindowContainer(externalWindow);
            }

(with externalParent required to reparent externalWindow before destroying the container).

Except that when I do this, I get 2 windows (neither of which will show my content), and the original window gets resized even when I take care not to ask for that (not directly at least).

I also see a series of

QWidget::paintEngine: Should no longer be called
QPainter::begin: Paint device returned engine == 0, type: 1

on the terminal which I don't see if I just create a new QWidget .

I guess I must be missing something?

Thanks,
R.

PS: goal here is to convert an old KDE4 screensaver to Qt5 - a cute project for a steamy sunday afternoon ;)


More information about the Interest mailing list