0

maybe someone have an idea how fix such problem: By following that tutorial https://doc-snapshots.qt.io/interfaceframework/qtinterfaceframework-interfaceframework-qface-tutorial-example.html and using examples I managed to create working simulation backend.

So if my project structure looks like that:

-root
--CMakeLists.txt
--app
  --CMakeLists.txt
  --src
  --res
--backend_simulator
  --CMakeLists.txt
--frontentd
  --CMakeLists.txt
--imports
  --CMakeLists.txt

main.cpp:

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);
// adding my imports folder
engine.addImportPath(app.applicationDirPath() + "/imports");

engine.load(url);

Everything works well, but only if I moved imports, backend_simulator and frontend into new middleware folder which simply added those folders by CMakeLists, plugin cannot be loaded.

-root
--CMakeLists.txt
--app
  --CMakeLists.txt
  --src
  --res
--middleware
  --CMakeLists.txt
  --backend_simulator
    --CMakeLists.txt
  --frontentd
    --CMakeLists.txt
  --imports
    --CMakeLists.txt

My import path is also changed to:

engine.addImportPath(app.applicationDirPath() + "/middleware/imports");

During runtime I got:

path/to/build/my_module.dll: The specified module could not be found.

Marcin_cyna
  • 97
  • 1
  • 1
  • 6
  • You probably have something wrong with your cmake make sure that `middleware` folder is being copied to the build folder. – ניר Jul 16 '22 at 20:29
  • Middleware folder is copied correctly and everything looks exactly the same. That's strange to me. Maybe qml cannot find some dependencies. – Marcin_cyna Jul 16 '22 at 20:37

1 Answers1

0

The answer is to putting all output folders in the build directory and get rid of Middleware folder. In such case QML have no problem with locating plugins and qmls.

Marcin_cyna
  • 97
  • 1
  • 1
  • 6