Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "GTK" warning for Native QFileDialog under Linux

"GTK" warning for Native QFileDialog under Linux

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 10.7k Views
  • 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.
  • J Offline
    J Offline
    JonB
    wrote on 15 Dec 2017, 10:54 last edited by JonB
    #1

    The following question will need a Qt expert who is prepared to look at the Qt source code!

    • It definitely happens under Linux Ubuntu with GNOME desktop.
    • I do not know whether it happens under Linux with other desktops.
    • I do not know whether it happens under Windows.

    Someone will have to be kind enough to try and see!

    If you open the Native (not Qt) QFileDialog (e.g. QFileDialog.getOpenFileName(parent, caption, directory, filter, initialFilter, options)), you always get a warning:

    Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

    This is explained (to some extent) in, say, https://stackoverflow.com/questions/44392504/run-python-gtk3-dialog-or-message-dialog-without-no-transient-parent-warning or https://stackoverflow.com/questions/29883211/gtkdialog-mapped-without-a-transient-parent

    Note that this warning still occurs whatever widget I pass as parent to QFileDialog, I have tried the calling Dialog widget, the Main Window and NULL/None to no effect.

    The warning does not matter so much inside a debugger, but it appears in the output from my application, e.g. in a terminal window if I invoke it from there. If you are an expert you will know why running my app with 2>/dev/null is not a good solution!

    If I understand those posts (especially https://stackoverflow.com/questions/44392504/run-python-gtk3-dialog-or-message-dialog-without-no-transient-parent-warning) correctly, it's down to how Qt source code --- which I take to be using GTK --- actually invokes the native file dialog. You would have thought it was passing the parent I give to QFileDialog, but maybe not?

    Can anyone see what's going on in the source for this? Given that, is there any possible workaround for me?

    1 Reply Last reply
    0
    • J jsulm
      20 Dec 2017, 05:22

      @mrjj Yes, the native dialog is GTK, but there is no other GTK window to use as parent, right?

      J Offline
      J Offline
      JonB
      wrote on 20 Dec 2017, 09:25 last edited by JonB
      #10

      @jsulm , @mrjj
      Ah, now it is beginning to become clearer! I think you're saying:

      • The native file dialog is a special kind of window: a "GTK" window. (This applies to Linux/X11? Ubuntu? Unity desktop only?)
      • It would like another GTK window as its parent.
      • But the Qt window which is its parent in QFileDialog is not a GTK window.
      • So the code passes 0/NULL for the parent, and that causes the warning.

      Right?

      J 1 Reply Last reply 20 Dec 2017, 09:31
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 15 Dec 2017, 22:15 last edited by
        #2

        Hi,

        From a quick look, it doesn't seem there's anything that can be done currently see here.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        J 1 Reply Last reply 19 Dec 2017, 08:25
        2
        • S SGaist
          15 Dec 2017, 22:15

          Hi,

          From a quick look, it doesn't seem there's anything that can be done currently see here.

          J Offline
          J Offline
          JonB
          wrote on 19 Dec 2017, 08:25 last edited by
          #3

          @SGaist
          Thank you for that. I note that the call seems to be:

          gtk_file_chooser_dialog_new("", 0, ...)

          That 0 is for parent, which I understand to be the cause of the warning. Seems strange that the "parent" we pass to QFileDialog function does not get passed down to native dialog call?

          J 1 Reply Last reply 19 Dec 2017, 11:27
          0
          • J JonB
            19 Dec 2017, 08:25

            @SGaist
            Thank you for that. I note that the call seems to be:

            gtk_file_chooser_dialog_new("", 0, ...)

            That 0 is for parent, which I understand to be the cause of the warning. Seems strange that the "parent" we pass to QFileDialog function does not get passed down to native dialog call?

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 19 Dec 2017, 11:27 last edited by
            #4

            @JNBarchan said in "GTK" warning for Native QFileDialog under Linux:

            Seems strange that the "parent" we pass to QFileDialog function does not get passed down to native dialog call?

            Because it can't. GTK does not know anything about any Qt classes - so it cannot use Qt classes as parents.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            J 1 Reply Last reply 19 Dec 2017, 12:07
            0
            • J jsulm
              19 Dec 2017, 11:27

              @JNBarchan said in "GTK" warning for Native QFileDialog under Linux:

              Seems strange that the "parent" we pass to QFileDialog function does not get passed down to native dialog call?

              Because it can't. GTK does not know anything about any Qt classes - so it cannot use Qt classes as parents.

              J Offline
              J Offline
              JonB
              wrote on 19 Dec 2017, 12:07 last edited by JonB
              #5

              @jsulm
              Sorry, yes, I meant, when we pass a Qt parent widget as parent to QFileDialog it would pass the corresponding native window onto GTK level as parent. But I don't know anything about GTK!

              J 1 Reply Last reply 19 Dec 2017, 12:23
              0
              • J JonB
                19 Dec 2017, 12:07

                @jsulm
                Sorry, yes, I meant, when we pass a Qt parent widget as parent to QFileDialog it would pass the corresponding native window onto GTK level as parent. But I don't know anything about GTK!

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 19 Dec 2017, 12:23 last edited by
                #6

                @JNBarchan But since it is a Qt application there is no native GTK window. Qt does not use GTK on Linux - as far as I know it draws by itself.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                M 1 Reply Last reply 19 Dec 2017, 19:25
                0
                • J jsulm
                  19 Dec 2017, 12:23

                  @JNBarchan But since it is a Qt application there is no native GTK window. Qt does not use GTK on Linux - as far as I know it draws by itself.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 19 Dec 2017, 19:25 last edited by
                  #7

                  @jsulm
                  But a native QFileDialog might be GTK ?

                  J 1 Reply Last reply 20 Dec 2017, 05:22
                  0
                  • M mrjj
                    19 Dec 2017, 19:25

                    @jsulm
                    But a native QFileDialog might be GTK ?

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 20 Dec 2017, 05:22 last edited by
                    #8

                    @mrjj Yes, the native dialog is GTK, but there is no other GTK window to use as parent, right?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    M J 2 Replies Last reply 20 Dec 2017, 07:07
                    1
                    • J jsulm
                      20 Dec 2017, 05:22

                      @mrjj Yes, the native dialog is GTK, but there is no other GTK window to use as parent, right?

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 20 Dec 2017, 07:07 last edited by
                      #9

                      @jsulm
                      Ah in that way. yes that would be hard to have in plain Qt app.

                      1 Reply Last reply
                      0
                      • J jsulm
                        20 Dec 2017, 05:22

                        @mrjj Yes, the native dialog is GTK, but there is no other GTK window to use as parent, right?

                        J Offline
                        J Offline
                        JonB
                        wrote on 20 Dec 2017, 09:25 last edited by JonB
                        #10

                        @jsulm , @mrjj
                        Ah, now it is beginning to become clearer! I think you're saying:

                        • The native file dialog is a special kind of window: a "GTK" window. (This applies to Linux/X11? Ubuntu? Unity desktop only?)
                        • It would like another GTK window as its parent.
                        • But the Qt window which is its parent in QFileDialog is not a GTK window.
                        • So the code passes 0/NULL for the parent, and that causes the warning.

                        Right?

                        J 1 Reply Last reply 20 Dec 2017, 09:31
                        0
                        • J JonB
                          20 Dec 2017, 09:25

                          @jsulm , @mrjj
                          Ah, now it is beginning to become clearer! I think you're saying:

                          • The native file dialog is a special kind of window: a "GTK" window. (This applies to Linux/X11? Ubuntu? Unity desktop only?)
                          • It would like another GTK window as its parent.
                          • But the Qt window which is its parent in QFileDialog is not a GTK window.
                          • So the code passes 0/NULL for the parent, and that causes the warning.

                          Right?

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 20 Dec 2017, 09:31 last edited by
                          #11

                          @JonB Yes, if you use native dialogs on Linux then Qt simply uses GTK dialogs (GTK is isn't related to Unity, see https://www.gtk.org/). Yes, as GTK does not know anything about Qt it is not possible to pass a parent to GTK dialogs from a Qt app.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          J 1 Reply Last reply 20 Dec 2017, 09:38
                          1
                          • J jsulm
                            20 Dec 2017, 09:31

                            @JonB Yes, if you use native dialogs on Linux then Qt simply uses GTK dialogs (GTK is isn't related to Unity, see https://www.gtk.org/). Yes, as GTK does not know anything about Qt it is not possible to pass a parent to GTK dialogs from a Qt app.

                            J Offline
                            J Offline
                            JonB
                            wrote on 20 Dec 2017, 09:38 last edited by
                            #12

                            @jsulm
                            All makes sense now! I had assumed that a normal Qt (X11?) window/dialog would serve as the parent for (what turns out to be a GTK) native file dialog. Now I get the problem, and the reason for the warning!

                            1 Reply Last reply
                            0

                            1/12

                            15 Dec 2017, 10:54

                            • Login

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