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. Question on desktop layout with multiple-monitors

Question on desktop layout with multiple-monitors

Scheduled Pinned Locked Moved General and Desktop
desktoprectmonitormultiple
2 Posts 2 Posters 2.4k Views
  • 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.
  • P Offline
    P Offline
    pmh4514
    wrote on last edited by
    #1

    I am building a QWidgets based desktop application for Windows. The application consists of several windows which can be placed anywhere on the desktop, including across multiple monitors. On shutdown, each of these windows stores in the registry (via. QSettings) its position, and later when the application is run again, each window returns to its last position. This all works just fine.

    The problem I'm trying to work now is, when a user re-runs the application with say one monitor attached. I need to "pull in" each stored position to fit within the current monitor.

    Say for instance, I last saved with 2 monitors, and my position value in settings is @Point(-1200 500) - it was off on the left in the muliti-monitor setup.

    So I figured I could use QApplication::desktop()->screenGeometry() to find the desktop rect, check that the window will fit, and adjust it as needed.

    But to my surprise, when I ran this first on a multi-monitor setup, QApplication::desktop()->screenGeometry(); only returned a rect representing the primary display.

    I guess the question is, if I have a stored window position of, for example @Point(-1200 500) how can I determine if that will put it visible on an actual display, or if I need to offset it?

    mrjjM 1 Reply Last reply
    0
    • P pmh4514

      I am building a QWidgets based desktop application for Windows. The application consists of several windows which can be placed anywhere on the desktop, including across multiple monitors. On shutdown, each of these windows stores in the registry (via. QSettings) its position, and later when the application is run again, each window returns to its last position. This all works just fine.

      The problem I'm trying to work now is, when a user re-runs the application with say one monitor attached. I need to "pull in" each stored position to fit within the current monitor.

      Say for instance, I last saved with 2 monitors, and my position value in settings is @Point(-1200 500) - it was off on the left in the muliti-monitor setup.

      So I figured I could use QApplication::desktop()->screenGeometry() to find the desktop rect, check that the window will fit, and adjust it as needed.

      But to my surprise, when I ran this first on a multi-monitor setup, QApplication::desktop()->screenGeometry(); only returned a rect representing the primary display.

      I guess the question is, if I have a stored window position of, for example @Point(-1200 500) how can I determine if that will put it visible on an actual display, or if I need to offset it?

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @pmh4514

      maybe you can use the QDesktopWidget

      int QDesktopWidget::screenNumber(const QWidget * widget = 0) const
      Returns the index of the screen that contains the largest part of widget, or -1 if the widget not on a screen.
      
      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