Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. [Solved] Qt5 QOpenglWindow + QPainter: how to get resolution independence ?
Forum Updated to NodeBB v4.3 + New Features

[Solved] Qt5 QOpenglWindow + QPainter: how to get resolution independence ?

Scheduled Pinned Locked Moved Game Development
2 Posts 1 Posters 1.6k 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.
  • S Offline
    S Offline
    sapr
    wrote on last edited by
    #1

    hello,

    just trying the new QOpenglWindow class introduced in Qt 5.4 with QPainter, but i would like to achieve resolution independence so everything looks good no matter the screen resolution (assuming the aspect ratio is kept).

    for instance, if i draw a rect in 10,10 with 20 width, 20 height, no matter the screen resolution the square will always be in the same location with the same size.

    maybe using hardcoded values for coordinates and sizes is not the best way, so how do Qt game developers solve this problem?

    thanks in advance.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sapr
      wrote on last edited by
      #2

      i managed to get an answer while googling, so in case anyone wonders in the future about this problem here is the solution: http://doc.qt.io/qt-5/coordsys.html

      basically QPainter has a setWindow() method that allows us to setup logical coordinates that get transformed to the physical coordinates (that one can change with the setViewport() method).

      anyway sorry for creating a thread about this.

      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