Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QFileDialog: GtkDialog mapped without a transient parent

Tags:

c++

qt

I've a source code snippet of a program written with Qt in C++, running under Linux, that creates a QFileDialog for opening an existing file. If I execute this, everything seems to work alright but when the dialog was created I got a warning saying "Gtk-Message: GtkDialog mapped without a transient parent".

In another thread I figured out that calling this function "gtk_window_set_transient_for()" fixes this error. But this function is part of the GTK library but I use the Qt framework. So are there any solutions to fix this error?

Parent of this dialog is a QMainWindow:

QString filename = QFileDialog::getOpenFileName(this, "Open File");
like image 827
0x1C1B Avatar asked Dec 16 '17 16:12

0x1C1B


1 Answers

From what I can tell from reading https://forum.qt.io/topic/85997/gtk-warning-for-native-qfiledialog-under-linux this is an issue within Qt, that we as Qt users can not directly address (and even if, we really would not want to as part of the appeal of Qt is the cross platform support). Even fixing it within in Qt it self appears to be hard, as a QWidget can not be the parent of a GTK dialog.

The only thing that springs to my mind is that it might be possible redirect the error message "somehow" to suppress it.

like image 55
sarowie Avatar answered Nov 13 '22 14:11

sarowie