Results 1 to 3 of 3

Thread: QDesktopWidget and multiple monitors

  1. #1
    Join Date
    Oct 2015
    Posts
    45
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QDesktopWidget and multiple monitors

    I want to position my main window at start up.

    It appears QDesktopWidget().screenGeometry() returns a QRect().

    This appears to only have the width of one monitor of the virtual desktop (this is on Linux). In this particular set of hardware that's 0,0,1920,1080.

    I can see with .screenCount that there are two monitors and .screenGeometry(x) returns the QRect of the associated screen (i.e. x = 0 or x = 1)

    This is a QDialog set geometry will size the dialog, but, I don't see how to get it onto a specific screen (i.e. 0 or 1)

    Confuse.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QDesktopWidget and multiple monitors

    QDesktopWidget is derived from QWidget. You can call QWidget::width() and QWidget::height() on the QDesktopWidget instance, and that will return the dimensions of the entire virtual screen (i.e. the width of both screens combined).

    Your display driver setup is what determines which screen is 0 and which is 1; most of the time systems are configured so screen 0 is on the left.

    So I am pretty sure the way you get your app to appear on screen 1 is to get the width of screen 0, then call setPos() on your top-level widget (QMainWindow) so that its x coordinate is greater than the width of screen 0. I don't have a dual screen setup so I can't test it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    drmacro (7th August 2017)

  4. #3
    Join Date
    Oct 2015
    Posts
    45
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QDesktopWidget and multiple monitors

    Seems that is how it works.

Similar Threads

  1. Two monitors, two forms
    By Victor007 in forum Qt Programming
    Replies: 1
    Last Post: 18th July 2013, 23:43
  2. qt with multiple monitors
    By denizlitr in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 15th May 2013, 10:48
  3. Replies: 3
    Last Post: 13th September 2012, 17:43
  4. Large desktop for Multiple Display Monitors
    By yxtx1984 in forum Qt Programming
    Replies: 5
    Last Post: 23rd December 2011, 11:37
  5. QGLWidget with multiple monitors
    By Rayven in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2006, 11:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.