Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, April 2008
QGraphicsView and sceen dimensions


Message 1 in thread

I am trying a scale a QGraphicsView widget so that the item dimensions measure 
up to the actual physical dimensions. For this i tried using 
QGraphicsView::widthMM() etc. but noticed that they all yielded wrong 
results.

My screen has a resolution of 1280*800 and measures 263mm*163mm physically. 
The API's yield wrong results:
width() == 640, height() == 480;
widthMM() == 161 * heigthMM() == 120;
logicalDpiX() == logicalDpiY == 101;

Sure enough none of these are correct. Is my understanding correct? Is there 
another way to achieve what i want?

Im running Kubuntu 8.04 Amd64 with Qt 4.3.4
-- 
 [ signature omitted ] 

Message 2 in thread

On Tuesday 08 April 2008 17:42:44 kitts wrote:
> I am trying a scale a QGraphicsView widget so that the item dimensions
> measure up to the actual physical dimensions. For this i tried using
> QGraphicsView::widthMM() etc. but noticed that they all yielded wrong
> results.
>
> My screen has a resolution of 1280*800 and measures 263mm*163mm physically.
> The API's yield wrong results:
> width() == 640, height() == 480;
> widthMM() == 161 * heigthMM() == 120;
> logicalDpiX() == logicalDpiY == 101;

640 pixels / 101 dots-per-inch = 6.33 inches = 160.95 mm

Sounds correct to me. But:
1280 pixels / 101 dots-per-inch = 12.67 inches = 321.9 mm

Check if your system's DPI info is correct. On my system:

$ xdpyinfo | grep -E '(dots|millimeters)'
  dimensions:    3360x1050 pixels (948x303 millimeters)
  resolution:    90x88 dots per inch

-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 3 in thread

On Tuesday 08 April 2008 21:29:00 Thiago Macieira wrote:
> On Tuesday 08 April 2008 17:42:44 kitts wrote:
> > I am trying a scale a QGraphicsView widget so that the item dimensions
> > measure up to the actual physical dimensions. For this i tried using
> > QGraphicsView::widthMM() etc. but noticed that they all yielded wrong
> > results.
> >
> > My screen has a resolution of 1280*800 and measures 263mm*163mm
> > physically. The API's yield wrong results:
> > width() == 640, height() == 480;
> > widthMM() == 161 * heigthMM() == 120;
> > logicalDpiX() == logicalDpiY == 101;
>
> 640 pixels / 101 dots-per-inch = 6.33 inches = 160.95 mm
>
> Sounds correct to me. But:
> 1280 pixels / 101 dots-per-inch = 12.67 inches = 321.9 mm
>
> Check if your system's DPI info is correct. On my system:
>
> $ xdpyinfo | grep -E '(dots|millimeters)'
>   dimensions:    3360x1050 pixels (948x303 millimeters)
>   resolution:    90x88 dots per inch

You are right. My system settings DPI is wrong but the resolution is correct.
$ xdpyinfo | grep -E '(dots|millimeters)'
  dimensions:    1280x800 pixels (322x201 millimeters)
  resolution:    101x101 dots per inch

I wonder how i can correct it or work around it. Other applications (oowriter, 
etc.) show actual physical size when set to actual size (zoom 100%).
-- 
 [ signature omitted ] 

Message 4 in thread

On Tuesday 08 April 2008 21:41:34 kitts wrote:
> On Tuesday 08 April 2008 21:29:00 Thiago Macieira wrote:
> > On Tuesday 08 April 2008 17:42:44 kitts wrote:
> > > I am trying a scale a QGraphicsView widget so that the item dimensions
> > > measure up to the actual physical dimensions. For this i tried using
> > > QGraphicsView::widthMM() etc. but noticed that they all yielded wrong
> > > results.
> > >
> > > My screen has a resolution of 1280*800 and measures 263mm*163mm
> > > physically. The API's yield wrong results:
> > > width() == 640, height() == 480;
> > > widthMM() == 161 * heigthMM() == 120;
> > > logicalDpiX() == logicalDpiY == 101;
> >
> > 640 pixels / 101 dots-per-inch = 6.33 inches = 160.95 mm
> >
> > Sounds correct to me. But:
> > 1280 pixels / 101 dots-per-inch = 12.67 inches = 321.9 mm
> >
> > Check if your system's DPI info is correct. On my system:
> >
> > $ xdpyinfo | grep -E '(dots|millimeters)'
> >   dimensions:    3360x1050 pixels (948x303 millimeters)
> >   resolution:    90x88 dots per inch
>
> You are right. My system settings DPI is wrong but the resolution is
> correct. $ xdpyinfo | grep -E '(dots|millimeters)'
>   dimensions:    1280x800 pixels (322x201 millimeters)
>   resolution:    101x101 dots per inch
>
> I wonder how i can correct it or work around it. Other applications
> (oowriter, etc.) show actual physical size when set to actual size (zoom
> 100%).

I guess i was wrong in my approach when i assumed that those API's always 
provided the screens dimensions. The correct way was

    QWidget *screen = 
QApplication::desktop()->screen(QApplication::desktop()->screenNumber(this));

Where the this pointer refers to the QGraphicsView widget. One can then use 
the variable "screen" for dimensions.
-- 
 [ signature omitted ]