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. QT - C++ with QML - Integrate an QML app with an C++ app
Forum Updated to NodeBB v4.3 + New Features

QT - C++ with QML - Integrate an QML app with an C++ app

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 223 Views 1 Watching
  • 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.
  • V Offline
    V Offline
    Vildnex
    wrote on last edited by
    #1

    Is there any way how can I integrate a QML application within one with C++?


    WHAT I HAVE?

    I have an application made with C++ and ui files which should be the main application, and also I have another one where has just some screens and views made in QML.


    THE PROBLEM

    Is there any way in witch I can get the pages writen in QML and access them within the C++ application? The reasone I'm asking this is because I've saw that that the actually main it's totally different.

    C++ main:

    QApplication a(argc, argv);
    MainWindow w(&a);
    w.show();
    return a.exec();
    

    QML main:

    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
    QGuiApplication app(argc, argv);
    
    qmlRegisterType<MovieListModel>("MovieListModel", 1, 0, "MovieListModel");
    qmlRegisterType<MovieModel>("MovieModel", 1, 0, "MovieModel");
    
    
    QQmlApplicationEngine engine;
    const QUrl url(QStringLiteral("qrc:/main.qml"));
    
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) {
    if (!obj && url == objUrl)
        QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);
    
    return app.exec();
    

    QUESTION

    How can I combine those 2 applications, or it's at even possible to combine them in a way that if in my application I will click on a button to go on a page from an UI file (or generated directly from C++ code) and if I will click on another button to go on an QML page?

    If any of you knows how can I do this please let me know, because everything which I could find on google it's how to have an QML file as ui and to use some C++ as backend for that specific UI. But nothing regarding how to combine both in terms of UI.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by Asperamanca
      #2

      You can have a normal widget-based application (with widgets and ui-Files and all that), and show QML files inside a QQuickWidget

      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