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] Get the availableGeometry of monitor WITH the taskbar on Windows
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Get the availableGeometry of monitor WITH the taskbar on Windows

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.7k 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.
  • H Offline
    H Offline
    holygirl
    wrote on last edited by
    #1

    While in the showMaximized mode, I'm trying to set a background image to my mainwindow by obtaining the size of the screen using

    @
    QRect rect = desktopWidget->availableGeometry();
    @

    But this returns the size of the screen excluding the taskbar. I read in the documentation that if int screen = -1 then the whole screen would be considered. Where do I specify the parameter? I tried

    @
    QRect rect = desktopWidget->availableGeometry(int screen = -1);
    @

    and

    @
    int screen = -1;
    QRect rect = desktopWidget->availableGeometry(screen);
    @

    But I suppose the above two methods are syntactically wrong. Could someone please help me in this regard?
    Thanks.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vidar
      wrote on last edited by
      #2

      If you're using Qt 5 you could use the QScreen class ( QScreen::geometry ).

      1 Reply Last reply
      0
      • U Offline
        U Offline
        utcenter
        wrote on last edited by
        #3

        Yes, according to the documentation that method should indeed return the full resolution of the display. Having the parameter "= -1" simply sets a "default" value to call the method without any parameter and use -1.

        Keeping in mind 99.99% of the screens out there are with standard resolutions or aspect ratios, you could easily calculate the actual size.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vidar
          wrote on last edited by
          #4

          P.S. using availableGeometry with -1 won't help. -1 is the screen no.
          You could also try to use QDesktopWidget::screenGeometry instead

          1 Reply Last reply
          0
          • H Offline
            H Offline
            holygirl
            wrote on last edited by
            #5

            Thank you, vidar. Yes, I'm using Qt 5 and using screenGeometry helped achieve what I was trying to do. Thank you so much.

            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