logicalDpiX/Y on QPixmap

Jeremy Sanders jss at ast.cam.ac.uk
Sat Jan 28 16:42:45 CET 2006


Hi -

I'm running the latest version of Q...3/Windows, compiled on Mingw on 
Windows XP (this also occured on 2000). If I print out the logicalDpiX() 
and logicalDpiY() on a QPaintDeviceMetrics object generated from a painter 
on a QPixmap, then I get really silly values (102 and 25 DPI for X and Y). 
On Linux it returned the Dpi of the screen (96 DPI). QPaintDeviceMetrics 
works for windows themselves. I should say that I'm using PyQt (though I 
don't think this is PyQt specific).

I include a PyQt program to demonstrate the problem. The two DPI values 
should be the same.

Thanks

Jeremy

-- 
Jeremy Sanders <jss at ast.cam.ac.uk>   http://www-xray.ast.cam.ac.uk/~jss/
X-Ray Group, Institute of Astronomy, University of Cambridge, UK.
Public Key Server PGP Key ID: E1AAE053
-------------- next part --------------
import sys
import qt

class MyWidget(qt.QVBox):
    def __init__(self, parent=None, name=None):
        qt.QVBox.__init__(self, parent, name)

        quit = qt.QPushButton("Quit", self, "quit")
        self.connect(quit, qt.SIGNAL("clicked()"), qt.qApp, qt.SLOT("quit()"))


        p = qt.QPixmap(100,100)

        painter = qt.QPainter(p)

        metrics = qt.QPaintDeviceMetrics(painter.device())

        print "Pixmap DPI:", metrics.logicalDpiX(), metrics.logicalDpiY()

        

        painter = qt.QPainter(self)
        metrics = qt.QPaintDeviceMetrics(painter.device())
        print "Window DPI:", metrics.logicalDpiX(), metrics.logicalDpiY()
        
a = qt.QApplication(sys.argv)

w = MyWidget()
a.setMainWidget(w)
w.show()
sys.exit(a.exec_loop())



More information about the kde-cygwin mailing list