Switching from QQuickView to QMLApplicationEngine
Unsolved
General and Desktop
-
I need to use an ApplicationWindow as root item in my QML, so I had to switch to QMLApplicationEngine. This is my old code:
int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); qmlRegisterType<Game>("Game", 1, 0, "Game"); QQuickView view; QSurfaceFormat format = view.format(); format.setSamples(16); view.setFormat(format); view.setSource(QUrl("qrc:///main.qml")); view.show(); return app.exec(); }
And this is my new code:
int main(int argc, char *argv[]) { QGLFormat fmt; fmt = QGLFormat::defaultFormat(); fmt.setSamples(16); QGLFormat::setDefaultFormat(fmt); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); qmlRegisterType<Game>("Game", 1, 0, "Game"); QQmlApplicationEngine engine; engine.load(QUrl(QLatin1String("qrc:/main.qml"))); return app.exec(); }
So as you can see, in the new code I set the samples to 16 as well. Now I do some drawing in my code, with the old code I get results like this:
With the new code however I get results like this:
You can ignore that I changed the items from something like a N to a square. Other than that there are huge differences in the drawing. To me it seems like there is no Anti aliasing, correct? There is stuff like holes in the lines and the image is not so crisp.
How can I get the same rendering results with QML ApplicationEngine? Does anyone know what I am missing?