Results 1 to 4 of 4

Thread: pixel to inch or mm

  1. #1
    Join Date
    Mar 2011
    Posts
    42
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default pixel to inch or mm

    hi, in qt embeded, have an function change pixel to inch or mm. before i check qt assisent, i find a QScreen class, it have some information about screen, but i don't know how to use it, anyone have an exam. thanks.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: pixel to inch or mm

    Use the QPainter to get the QPaintDevice and then use the various metrics it provides. These may not be entirely reliable though.

  3. #3
    Join Date
    Jun 2009
    Posts
    37
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: pixel to inch or mm

    First take a look at this thread
    http://www.qtcentre.org/threads/1559...een-pixel-size

    then if you can't get it

    Qt Code:
    1. int PixelWidthDimension = myWidget->logicalDpiX(); //width dots per inch
    2. int PixelHeightDimesion = myWidget->logicalDpiY(); //width dots per inch
    3.  
    4. double inch = (double)myWidthInPixel / (double)PixelWidthDimension;
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Mar 2011
    Posts
    42
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: pixel to inch or mm

    thank you, i have finish my program, thanks your help.

Similar Threads

  1. Display GUI with pixel
    By arashadsaifi in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 19th January 2010, 21:23
  2. How do i display the rgb value of a pixel
    By davidw in forum Qt Programming
    Replies: 2
    Last Post: 17th May 2009, 23:51
  3. 1 pixel QSplitter
    By bunjee in forum Qt Programming
    Replies: 5
    Last Post: 4th March 2009, 12:12
  4. QPixmap pixel by pixel ?
    By tommy in forum Qt Programming
    Replies: 19
    Last Post: 3rd December 2007, 22:52
  5. Strange Unit em - same as inch? on XSLT-Fo format
    By patrik08 in forum General Programming
    Replies: 3
    Last Post: 15th July 2007, 23:46

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.