[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.


  • Lifetime Qt Champion

    Hi,

    Just replace QGuiApplication with QApplication. QApplication inherits from QGuiApplication.



  • Thanks, that worked!

    I have another error message but I will post that in a separate post.

    Thanks much.


  • Lifetime Qt Champion

    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 :)



  • [quote author="SGaist" date="1410808258"]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 :)[/quote]

    You got it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.