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. Verifying the validity of window position from a previously saved position
Qt 6.11 is out! See what's new in the release blog

Verifying the validity of window position from a previously saved position

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 973 Views 2 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.
  • C Offline
    C Offline
    cristeab
    wrote on last edited by
    #1

    Hi

    I am trying to check if the position previously saved of my window is valid for the available screen. My problem is that with 2 screens the saved position might have negative values. When I use a single screen, this position is no longer valid, but how can I verify the validity of the window position in a generic manner, when say multiple screens are available.

    regards
    Bogdan

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      You can get the QRect representing the whole virtual (multi-monitor) space using QDesktopWidget and then check if your stored point or rectangle is contained in the available space e.g.

      QRect storedGeometry = ...
      
      if(!QApplication::desktop()->geometry().contains(storedGeometry))
          storedGeometry =  ...//  adjust the stored geometry
      

      contains() also has an overload for QPoint if you don't have the whole QRect.

      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