Unsolved QFileDialog Error
-
I am using OpenFileDialog to load a file and this is the code.
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),QDir::homePath() , tr("Kml Files (*.kml)")); qDebug() << "Loading File"<< fileName; QFile file( fileName ); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in(&file);
But I am getting the dialog as shown here and so am unable to select the files. Any comments on why the filedialog is being displayed in this manner?
Note: This is called when load file is triggered on mainwindow.Does it have anything to do with the mainwindow layout?
-
Hi
That seems completely messed up ?
everything else works normally?Try to make small default application
and use the file open code.Does it still does it then?
-
@mrjj
No I tried the same code in a new project and it works :( -
Ok. so it is your project somehow?!?
And this happens as shoow as it open the dialog?
Does it only do it on ubuntu?
(the same code) -
Just a guess: What's the parent instance (
this
) that you pass to theQFileDialog::getOpenFileName(...)
method?
Is it an insvible window? (This should not be a problem but it seems that something influences the dialog box)
And: Does the dialog show up in fullscreen? Does the dialog look normal when you try to resize it using the mouse? -
No. Its the mainwindow already holding several widgets. Yes, the dialog shows up in full screen and also I am unable to resize it from the bottom
-
@saitej
Hm, I think the reason for the display problem is the fact that the dialog is in fullsize mode (I'm not sure if this is really supported - on the other hand there's no reason why it should lead to a mixed up layout). And I have no idea why the dialog runs in fullscreen.
Could you try once to passNULL
instead ofthis
just to see if the dialog layout changes? -
I tried by passing NULL and also made sure the mainwindow is not maximized but still same problem persists
-
I tried the same code in the same system. It works on a new project but not on an existing one. I am unable to find a valid reason for this unusual behaviour
-
@saitej
ok. its really , really odd.Could you try with the
QFileDialog::DontUseNativeDialog
flag and see if its the ubuntu dialog that is strange? -
@mrjj
It didn't work :( -
I will try to implement the same in qml. How to open file dialog in qml through a slot/function?
-
Same thing happens even with flag?
Hmm. I really have no idea what can do this.
Also since it works normally in default app and
the static call is the same.Have you tried some of the other dialogs ? like COlorDIalog?
-
@mrjj
Nope. Any links would help -
Its like the getOpenFileName, just to get a color and not a filename.
http://doc.qt.io/qt-5/qcolordialog.html
I just wonder if that is funky too.
-
-
@mrjj
QColorDialog works fine!! -
@saitej
Ok very strange..Im not into QML but this seems to be sample
http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html#details -
-
@saitej
That's really strange. Can your share a minimal runnable code example so that other users can try to reproduce the behaviour on their platforms?