0

I have an issue using the static member functions of QFileDialog. When the file explorer dialog opens, another window is opened in background, but contains nothing : it isn't just painted. It closes when I select something and close the file dialog but it remains annoying.

I'd like to get rid of it. I read an existing thread about this issue that suggested to give a parent for the dialog as argument to the function. So I used a very simple parent widget :

QString str = QFileDialog::getOpenFileName(new QWidget(),trUtf8("Choose a file"));

And then I had no more one annoying window, but two. The first one was closed when I closed the file explorer dialog, but the second one remained until I closed the application.

I think the second window was the QWidget I gave as parent. The default value for the first argument is 0, but maybe Qt creates a QWidget() in this case.

I tried to create an independant QWidget and hide it before calling getOpenFileName() :

QWidget *w = new QWidget();
w->hide();
QString str = QFileDialog::getOpenFileName(w,trUtf8("Choose a file"));

But it doesn't change anything, and I still get two unwanted windows. At last, I tried to use a QLabel as parent to see if it was really shown :

QLabel *l = new QLabel("Test");
QString str = QFileDialog::getOpenFileName(l,trUtf8("Choose a file"));

But it seems it is not. Obviously nothing is handling those windows... they aren't just painted, when you move a window on them, you can see the trace it leaves.

I ran out of ideas... does anyone have any other idea to solve that annoying problem ?

Community
  • 1
  • 1
lephe
  • 302
  • 4
  • 14

0 Answers0