Issue
I am trying to get the screen resolution from PySide:
class Prog(QtGui.QDialog):
def __init__(self):
super().__init__()
self.timer = QtCore.QTimer()
desktop = QtGui.QDesktopWidget()
dim = desktop.availableGeometry(desktop.primaryScreen())
print(dim)
print(desktop.width())
print(desktop.height())
print(QtGui.QApplication.desktop().screenGeometry())
app = QtGui.QApplication(sys.argv)
prog = Prog()
prog.show()
sys.exit(app.exec_())
I am on a macbook pro so I know the resolution is 2560-by-1600, but Qt seems to give the wrong answer consistently:
PySide.QtCore.QRect(0, 22, 1440, 874)
1440
900
PySide.QtCore.QRect(0, 0, 1440, 900)
did I do anything wrong here?
Solution
Nothing is wrong with Qt, you can read this doc: retina display support and mostly this part Mac OS X High-dpi Support
where you can find:
The key to the OS X high-dpi mode is that most geometry that was previously specified in device pixels are now in device-independent points. This includes desktop geometry (which on the 15 inch retina MacBook Pro is 1440×900 and not the full 2880×1800), window geometry and event coordinates. The CoreGraphics paint engine is aware of the full resolution and will produce output at that resolution. For example, a 100×100 window occupies the same area on screen on a normal and high-dpi screen (everything else being equal). On the high-dpi screen the window’s backing store contains 200×200 pixels.
and:
The main benefits of this mode is backwards compatibility and free high-dpi vector graphics. Unaware applications simply continue to work with the same geometry as before and can keep hardcoded pixel values. At the same time they get crisp vector graphics such as text for free. Raster graphics does not get an automatic improvement but is manageable. The downside is the inevitable coordinate system confusion when working with code that mixes points and pixels.
The scale factor between points and pixels is always 2x. This is also true when changing the screen resolution – points and pixels are scaled by the same amount. When scaling for “More Space” applications will render to a large backing store which is then scaled down to the physical screen resolution.
Answered By - Thomas Ayoub
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.