Important: Please read the Qt Code of Conduct -

QGLWidget/high-dpi: convert mouse position to GL pixels?

  • I'm using QGLWidget and I'm trying to reconcile the unit used by QGLWidget.resizeGL(w, h) (which appear to be "hardware" pixels) and the unit used by QMouseEvent.pos() (which appear to be "logical" pixel. There seem to be a factor of 2 between them. How can I obtain the right factor for my widget?

  • Never mind, I just figured it out:

    ratio = self.window().devicePixelRatio()

Log in to reply