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

  • 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.

  • 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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.