Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] How to use QDesktopWidget with QGuiApplication...
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to use QDesktopWidget with QGuiApplication...

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tmason101
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Just replace QGuiApplication with QApplication. QApplication inherits from QGuiApplication.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tmason101
        wrote on last edited by
        #3

        Thanks, that worked!

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

        Thanks much.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tmason101
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved