问题
I am using a QGraphicsScene with a QGraphicsView, as described in this document; I intend to eventually overlay Qt widgets on top of my OpenGL rendered scene.
When I launch a dummy application modeled after the tutorial above, the rendered view is heavily pixelated-- HiDPI isn't working at all. Per this document, I've manually added:
<key>NSHighResolutionCapable</key>
<string>True</string>
to the application's Info.plist file, still with no effect. (It seems this is supposed to default to true
anyway, so maybe that's not surprising).
Beyond the above, I haven't found what's needed to get HiDPI working. I am not using QtCreator, and my Qt install is macports' qt4-mac
. What am I missing?
回答1:
Qt5 enables HiDPI for the OpenGL context, but not for widgets and QGraphicsItems.
According to this bug, support for rendering widgets and QGraphicsItems on a QGLWidget in HiDPI is not yet supported; they will render at standard res and be resized.
QGraphicsView will render in HiDPI if it has an ordinary QWidget to back it. If it is possible to achieve the desired effect using QGraphicsItems without OpenGL, this may be preferable until HiDPI support is improved.
回答2:
I just found the solution: run your program with --graphicssystem native
. Or if you can alter the sources you can use QApplication::setGraphicsSystem("native");
.
来源:https://stackoverflow.com/questions/23985143/how-do-i-enable-hidpi-retina-support-in-a-qt4-opengl-application