[SOLVED] How to use QDesktopWidget with QGuiApplication...
-
Hello,
I am trying to build an OpenGL application based on this example code here:
http://qt-project.org/doc/qt-5/qtgui-openglwindow-example.html
I can get the example code to build but now I need a few more things like menus, toolbars, etc.
One of the first things I need is to detect the screen size and place the monitor on the second screen.
Therefore, I was attempting to use QDesktopWidget for this task.
I attempt to initialize the QDesktopWidget instance like so:
@QDesktopWidget* ScreenDetector = QApplication::desktop();@
But since I am using QGuiApplication instead of QApplication I get the following error:
"QWidget: Cannot create a QWidget with QApplication"
Is it possible to use QDesktopWidget and other desktop widgets with QGuiApplication?
Or should I be using another example for what I am trying to do?
Thank you for your time.
-
Hi,
Just replace QGuiApplication with QApplication. QApplication inherits from QGuiApplication.
-
You're welcome !
Since you have your widgets working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)