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()}
        }
    
    }
    
    

    0_1496827473797_Screenshot from 2017-06-07 11-00-02.png

    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.
    0_1496827485086_Screenshot from 2017-06-07 11-00-42.png
    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.


  • Moderators

    @summerfang

    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!


Log in to reply
 

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