How do I enable HiDPI (Retina) support in a Qt4 Op

2019-07-04 04:02发布

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?

2条回答
一夜七次
2楼-- · 2019-07-04 04:38

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.

查看更多
干净又极端
3楼-- · 2019-07-04 04:44

I just found the solution: run your program with --graphicssystem native. Or if you can alter the sources you can use QApplication::setGraphicsSystem("native");.

查看更多
登录 后发表回答