Results 1 to 11 of 11

Thread: Can't seem to get global screen position

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: Can't seem to get global screen position

    Quote Originally Posted by amleto View Post
    well, it kinda makes sense when you read:

    “For an application, the screen where the main widget resides is the primary screen. This is stored in the primaryScreen property.”
    - Coises.

    now you have to check that the sizes of the different screens always correspond correctly?
    But then I should get different screen resolutions for the primary screen each time. But the following always returns "QRect(1024,0 1366x768)"...
    Qt Code:
    1. QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen())
    To copy to clipboard, switch view to plain text mode 


    Quote Originally Posted by Coises View Post
    Per ChrisW67’s suggestion, what happens if you replace QApplication::desktop()->screenNumber() with QApplication::desktop()->screenNumber(widget), where widget is a pointer to your window widget? (See: QDesktopWidget::screenNumber)

    Similarly, note that QDesktopWidget::availableGeometry can take a QWidget* argument.
    Hm, when I try
    Qt Code:
    1. QApplication::desktop()->screenNumber(this)
    To copy to clipboard, switch view to plain text mode 
    I get a slightly different output to the qDebug() statement: "0 - 1 - 2". But again, it's the exact same no matter what screen I start the app on...
    I'll have a look at QDesktopWidget::availableGeometry() later-on when I'm back home... hopefully that'll work!!

  2. #2
    Join Date
    Nov 2009
    Posts
    129
    Thanks
    4
    Thanked 29 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't seem to get global screen position

    Quote Originally Posted by huilui View Post
    But again, it's the exact same no matter what screen I start the app on...
    For me, that would be where I give up, conclude that Qt has missed (again), and just work out how to do it with the native API for whatever operating system(s) this will run on.

    Based only on my quite limited personal experience, I’d put the odds at 50-50 that you’ll never find a pure Qt solution, so this where it become more time/cost-effective to forget Qt and use the native API while you still have a few shreds of sanity left.

  3. #3

    Default Re: Can't seem to get global screen position

    Quote Originally Posted by Coises View Post
    For me, that would be where I give up, conclude that Qt has missed (again), and just work out how to do it with the native API for whatever operating system(s) this will run on.

    Based only on my quite limited personal experience, I’d put the odds at 50-50 that you’ll never find a pure Qt solution, so this where it become more time/cost-effective to forget Qt and use the native API while you still have a few shreds of sanity left.
    Hm, I think you're right. It might be better to stop messing around with Qt trying to get that to work and just do it without Qt... It'l probably take a good while, but then it will (hopefully) work at least.

    Thanks to all of you guys for your help

  4. #4
    Join Date
    Nov 2009
    Posts
    129
    Thanks
    4
    Thanked 29 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't seem to get global screen position

    Quote Originally Posted by huilui View Post
    It'l probably take a good while, but then it will (hopefully) work at least.
    If it’s Windows, see the topics under:

    Multiple Display Monitors

    especially the example here:

    Positioning Objects on a Multiple Display Setup

    and the references here:

    Multiple Display Monitors Functions

    I only have one monitor here, so I can’t tell you if all that works as advertised. I imagine Qt is attempting to use those same functions. (To get an HWND from a Qt window, use QWidget::winId.)

  5. #5

    Default Re: Can't seem to get global screen position

    Thanks for the links coises!! However, my app is used mostly in Linux (don't know of anybody who tried to run it in Windows yet)...

Similar Threads

  1. Replies: 2
    Last Post: 26th April 2009, 07:34
  2. Mouse position on screen
    By Nippler in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2008, 14:22
  3. Setting manually cursor position on multi screen systems
    By irreriwan in forum Qt Programming
    Replies: 0
    Last Post: 4th March 2008, 09:47
  4. How to know current global mouse position?
    By Teerayoot in forum Qt Programming
    Replies: 2
    Last Post: 11th May 2007, 19:25
  5. positioning a window at a specific screen position
    By nupul in forum Qt Programming
    Replies: 3
    Last Post: 29th March 2006, 20:21

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
  •  
Qt is a trademark of The Qt Company.