I want to open a QFileDialog over a QQuickItem.
void
MyCoolQQuickItem::loadFileDialog()
{
QString filename = QFileDialog::getOpenFileName(this, "Open a file",
"C:\\path to my stuff\\", "*.*");
if(filename.size()>0) {
// load file and do stuff
}
}
My MyCoolQQuickItem is a Subclass of QQuickItem. And QFileDialog::getOpenFileName need a QWidget* as parent. If I pass a null_ptr instead, the dialog opens correctly as modal dialog. But after I close the dialog the wrong window gets the focus.
I tried to pass the window instead(this->window(), but I have a QQuickWindow, what also could not be parsed in a QWidget.
I could use the QML File-Dialog instead. http://qt-project.org/doc/qt-5/qml-qtquick-dialogs-filedialog.html
But I want to use a QFileDialog here. http://qt-project.org/doc/qt-5/qfiledialog.html
Any Idea how I can solve this?