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. Error when opens FileDialog
Qt 6.11 is out! See what's new in the release blog

Error when opens FileDialog

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 2.0k Views 1 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.
  • S Offline
    S Offline
    summerfang
    wrote on last edited by summerfang
    #1

    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.

    EddyE 1 Reply Last reply
    0
    • S summerfang

      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.

      EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by Eddy
      #2

      @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

      Qt Certified Specialist
      www.edalsolutions.be

      S 1 Reply Last reply
      0
      • EddyE Eddy

        @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

        S Offline
        S Offline
        summerfang
        wrote on last edited by
        #3

        @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!

        1 Reply Last reply
        0

        • Login

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