How do I enable HiDPI (Retina) support in a Qt4 OpenGL application?

亡梦爱人 提交于 2019-12-10 19:29:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!