Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Switching from QQuickView to QMLApplicationEngine
Forum Updated to NodeBB v4.3 + New Features

Switching from QQuickView to QMLApplicationEngine

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 499 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Magnus2552
    wrote on last edited by
    #1

    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:
    alt text
    With the new code however I get results like this:
    alt text
    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved