Close Qml-Part and let the QWidget-App running

  • I have a QWidget App with a Qml Camera-Part. When I click on a Button in the QWidget-App, the Qml-Part will be loaded:

        QQmlApplicationEngine engine;
    QApplication a(argc, argv);
    MainWindow w;;
    return a.exec();
    // MainWindow creates Recorder-instance and these calls the Load-method:
    void Recorder::Load() {

    When I am done with the recording of my media-files, I'm going to close the Qml-Part, but the QWidget- App should still running at all!

    I call this->engine.quit() in my C++ file, or Qt.quit() in my Qml-File, but either way the QWidget-App is closed also.

    How can I prevent this behavior?
    Ony the Qml Part should close, but not the QWidget App also.

    Thanks for help!

  • I think it's a pity that I have found little help in this forum so far. Neither to my own questions, nor by reading foreign contributions.

    Anyway ... I have a solution, but I do not know if it's not a bit dirty. When the signal is fired that a media stream is ready, I delete the recorder instance:

    void MainWindow::OnClosingPhotoRecorder(std::shared_ptr<QImage> photoImage)
        some code goes here...

    This deletion causes the Qml-object will close, but the QWidget app will continue to run.

  • Qt Champions 2018

    @peter-70 said in Close Qml-Part and let the QWidget-App running:

    I think it's a pity that I have found little help in this forum so far.

    You asked 14h ago, please be more patient. People here help voluntary.
    Deleting the recorder should be fine.

  • Moderators


    for(QObject *obj : engine.rootObjects()){

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.