Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QGLWidget/high-dpi: convert mouse position to GL pixels?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved Qt for Python
2 Posts 1 Posters 292 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abey79
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      abey79
      wrote on last edited by
      #2

      Never mind, I just figured it out:

      ratio = self.window().devicePixelRatio()

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved