Results 1 to 7 of 7

Thread: how to get screen pixel size?

  1. #1
    Join Date
    Apr 2008
    Posts
    17
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default how to get screen pixel size?

    Hi,

    Does anyone know how to get pixel size with Qt?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to get screen pixel size?

    Do you mean the resolution? Take a look at QDesktopWidget and what it offers.

  3. #3
    Join Date
    Apr 2008
    Posts
    17
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to get screen pixel size?

    wysota, I just need a pixel or screen width and height in millimeters. I have to draw symbols at the same dimension on defferent screens and resolutions.

  4. #4
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to get screen pixel size?

    Quote Originally Posted by kodiak View Post
    wysota, I just need a pixel or screen width and height in millimeters. I have to draw symbols at the same dimension on defferent screens and resolutions.

    All you can do is use the DPI that the system gives you to convert to a physical unit and then draw based on that. However, that DPI is not correct on most monitors, so drawing something to exactly the same physical size is practically impossible.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to get screen pixel size?

    The pixel size is in its nature resolution independent (as opposed to point size, or vice versa - in that case revert everything I say here), so if you count everything in logical pixels (and not points) you should get consistent sizes (this especially applies to fonts).

  6. #6
    Join Date
    Apr 2008
    Posts
    17
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to get screen pixel size?

    There is solution in QPaintDevice class. Methods widthMM() and heightMM() returns what I have been looking for!

  7. #7
    Join Date
    Aug 2006
    Posts
    250
    Thanks
    19
    Thanked 49 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to get screen pixel size?

    Quote Originally Posted by kodiak View Post
    There is solution in QPaintDevice class. Methods widthMM() and heightMM() returns what I have been looking for!
    Yes, they return a measurement in millimeters, but you can't actually trust the value that it gives you. Sure it'll be sort of correct, but if you verify it with a ruler it won't match up (unless your monitor has a perfect DPI setting, which is very unlikely, and most people don't).

  8. The following user says thank you to pherthyl for this useful post:

    kodiak (27th August 2008)

Similar Threads

  1. Point to Pixel Calculation on all screen
    By patrik08 in forum General Programming
    Replies: 0
    Last Post: 3rd April 2008, 08:10
  2. Replies: 1
    Last Post: 27th March 2008, 15:10
  3. screen size
    By eric in forum Qt Programming
    Replies: 2
    Last Post: 28th December 2007, 14:54
  4. how to get the screen size in qt2
    By pencilren in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2007, 03:47
  5. Replies: 1
    Last Post: 24th October 2006, 16:40

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.