Unsolved Error when opens FileDialog
-
I have a very simple example code,and when I clicked the button to open the filedialog, the dialog pops but the following errors appear and the program crashes. It's Qt 5.7 under Debian.
Error:
(NewOptisort:2246): GLib-GObject-WARNING **: cannot register existing type 'GdkWindow' (NewOptisort:2246): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed (NewOptisort:2246): GLib-GObject-CRITICAL **: g_type_register_static: assertion 'parent_type > 0' failed (NewOptisort:2246): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed
code:
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 import QtQuick.Dialogs 1.2 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") FileDialog { id:file } Button { id: button x: 93 y: 86 text: qsTr("Button") onClicked: {file.open()} } }
I found the reason may have something to do with openCV. In my .pro, I have LIBS +=
pkg-config opencv --libs
,
if I comment this line and rebuild the project, the error disappear. But the popped dialog has another layout, different from the look from the test with openCV. I don't know why this happens and I must use openCV and FileDialog together.
I spent already one day to delete the fragment installation packages I don't need in my system, doesn't help.
Thanks in advance for answering. -
I know you are using Qt5.7
But in the docs of Qt5.9 about FileDialog you can read :Availability
A native platform file dialog is currently available on the following platforms:- iOS
- Linux (when running with the GTK+ platform theme)
- macOS
- Windows
- Win RT
So I think you will have to take another approach if the newer Qt version says it only supports GTK+.
Also you could ask on the mailing lists if there is a workaround. Qt developers are more likely to hang out there. This is more a user oriented forum.
hope it helps.
Eddy
-
@Eddy Thanks a lot but I do have GTK+ and if I don't link to opencv the code works perfectly. I am kind of new and I don't know about the mailing list, I'll check it, thanks!