Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
5.9.6
-
None
-
* Windows 10 x64
* Qt 5.9.6 MSVC 2015 32 bit
Description
Attempt to open a default file dialog leads to an application crash/assert. Somethime the crash causes at changing the choosed file suffixes (png, jpg, ..) from the dialog's combobox. Seems, this crash occurred only at debugging (at least at debugging from QtC).
To use a default dialog, need to setup, e.g an non-existent theme in a code, like this:
qputenv("QT_QPA_PLATFORMTHEME","foo");
An application code is simple:
== main.cpp ==
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { qputenv("QT_QPA_PLATFORMTHEME","foo"); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
== main.qml ==
import QtQuick 2.9 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") Button { text: "Open Dialog" onClicked: fileDialog.open() } FileDialog { id: fileDialog title: "Please choose a photo" folder: shortcuts.pictures nameFilters: ["*.png", "*.jpg", "*.jpeg"] onAccepted: console.info("Selected: " + fileUrl) } }
Please see an attaches source project example too.