Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Application exits on second call to FileDialog.open()
Qt 6.11 is out! See what's new in the release blog

Application exits on second call to FileDialog.open()

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 555 Views 2 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.
  • Tom assoT Offline
    Tom assoT Offline
    Tom asso
    wrote on last edited by Tom asso
    #1

    My main.qml defines an instance of FileDialog called "fileDialog". The FileDialog is displayed properly the first time fileDialog.open() is invoked. However the next time fileDialog.open() is invoked, the application exits. It does NOT core dump. I see this behavior whether or not I actually select a file, or choose "Cancel". My main.qml also defines a MessageDialog called "quitDialog", which can be invoked multiple times with no problem. Why does my application exit the second time fileDialog.open() is invoked? I am running Qt 5.14.2 on Ubuntu 18.04.4.

    Here's main.qml:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick 2.9
    import QtQuick.Controls 2.3
    import QtQuick.Dialogs 1.1
    
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        menuBar: MenuBar {
            Menu {
                title: "File"
                Action { text: "Open grid" ;
                    onTriggered: { console.log("show file dialog")
                        fileDialog.open()}
                }
                Action { text: "Exit" ;
                    onTriggered: { console.log("exit");
                        quitDialog.open()
                    }
                }
    
            }
        }
    
        FileDialog {
             id: fileDialog
             title: "Open file"
             nameFilters: ["Grid files (*.grd)"]
             onAccepted: {
                 console.log("accepted " + fileUrl);
             }
         }
    
        MessageDialog {
              id: quitDialog
              title: "Quit?"
              icon: StandardIcon.Question
              text: "Quit application?"
              standardButtons: StandardButton.Yes |
                               StandardButton.No
              Component.onCompleted: visible = false
              onYes: Qt.quit(0)
              onNo: console.log("did not quit")
          }
    }
    

    My main.cpp is also very simple, and was auto-generated with qtcreator:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        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();
    }
    

    Thanks!

    1 Reply Last reply
    0
    • Tom assoT Offline
      Tom assoT Offline
      Tom asso
      wrote on last edited by
      #2

      Solved: my application generated this error message on exit:
      relocation error: /home/oreilly/Qt5.14.2/5.14.2/gcc_64/plugins/platformthemes/libqgtk3.so: symbol _ZdlPvm version Qt_5 not defined in file libQt5Core.so.5 with link time reference

      This message indicates that the application was compiled and linked with different flags that compiled the Qt5.14.2 libraries. I've recompiled the libraries, and now can call FileDialog.open() multiple times without a problem.

      1 Reply Last reply
      2

      • Login

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