Qt5 "Attempting to set screen in child window" many runtime warnings

In our Qt5-based application, the console displays messages such as:

0x1beccb0 void QWindowPrivate::setTopLevelScreen(QScreen*, bool) ( QScreen(0xd25b80) ): Attempt to set a screen on a child window. 

This does not prevent the application from starting, but I would like to fix them, since it tends to indicate that we are probably doing something wrong. The code is quite large (cannot be included in the message, it is: http://gforge.inria.fr/frs/?group_id=1465 ). I can't ask you to look at it (too big), but maybe you will have an idea with the following additional information:

  • Messages appear only under Linux, not under Windows

  • Our application is a three-dimensional fashion designer that has several QGLWidgets for displaying 3D content. If I delete QGLWidgets, the messages disappear.

  • In the debugger, if I set a breakpoint on QWindowPrivate :: setTopLevelScreen (), it is called:

    kernel /qwindow.cpp: 368 368 q-> connect (screen, SIGNAL (destroyed (QObject *)), q, SLOT (screenDestroyed (QObject *)));

Update1: I set a breakpoint on QMessageLogger :: warning (qDebug () is a macro that uses this function), now I can better see the stack, which looks like this:

 #0 0x00007fffefa50600 in QMessageLogger::warning() const@plt () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 #1 0x00007fffefa851cb in QWindowPrivate::setTopLevelScreen (this=0xd330e0, newScreen=0x7201a0, recreate=<optimized out>) at kernel/qwindow.cpp:371 #2 0x00007fffefa7f2f5 in QGuiApplicationPrivate::processWindowSystemEvent (e=e@entry=0x760600) at kernel/qguiapplication.cpp:1608 #3 0x00007fffefa631f8 in QWindowSystemInterface::sendWindowSystemEvents (flags=...) at kernel/qwindowsysteminterface.cpp:625 #4 0x00007fffeb7d4100 in userEventSourceDispatch (source=<optimized out>) at eventdispatchers/qeventdispatcher_glib.cpp:70 (More stack frames follow...) 

QGuiApplicationPrivate :: processWindowSystemEvent handles the QWindowSystemInterfacePrivate :: ThemeChange event:

 1608 case QWindowSystemInterfacePrivate::ThemeChange: 1609 QGuiApplicationPrivate::processThemeChanged( 1610 static_cast<QWindowSystemInterfacePrivate::ThemeChangeEvent *>(e)); 1611 break; 

Update2: Somewhere over there !! This is when I call setMinimumWidth () / setMinimumHeight () in a QGLWidget. Now I would like to know why ...

Update3: Additional Information: Messages are displayed only if there are two screens connected to my computer.

+8
qt5
source share
1 answer

Finally, I realized what was going on:

  • Warning messages occur when setMinimumWidth () / setMinimumHeight () is called on a QGLWidget on Linux with a two-screen display.

This is probably a bug in Qt. This probably won't be fixed, as the documentation recommends using the new QOpenGLWidget, which appeared in Qt 5.4 (note: "OpenGL" instead of "GL"), which I did, and the warning messages disappeared.

Edit: I saw a message from someone who had problems with text that doesn't display correctly with the new QOpenGLWidget, to which I reply: When using the new QOpenGLWidget, you need to make sure that it no longer has an independent OpenGL context, it shares OpenGL context with Qt (therefore, OpenGL states modified in the rendering function must be restored after exiting the rendering function, for example, blending mode).

+7
source share

All Articles