QFileDialog :: DontUseNativeDialog not working

I have a problem with a simple program. I open QFileDialog as follows:

QFileDialog fileDialog(this); fileDialog.setAcceptMode(QFileDialog::AcceptOpen); if (!fileDialog.exec()) return; 

However, it shows the Qt dialog box instead of the native Windows dialog box. I use Windows 7 x64, and I really prefer my own dialogue instead of Qt dialogue, because it is a bit more attractive. However, I read, and I found that this can be changed using:

 fileDialog.setOption(QFileDialog::DontUseNativeDialog, false); 

The fact is that I do not get the native Windows dialog, and Qt is one, so this option does not work ... Does anyone know how to solve this problem without using static members?

I do not want to use static elements because they have a memory leak problem or something like that, because if you open several new dialogs with a static member, the memory used by your program will increase and increase, however, using the dialogue previously saved with a pointer does not have this problem.

So, if someone has an answer about these two things (a problem with the internal dialogue and a problem with a memory leak), tell me.

Thanks.

+8
qt qfiledialog
source share
3 answers

Internal dialogs do not support the full set of functions open by the QFileDialog class. That's why they are only available through static short-circuit functions called getOpenFileName() , getSaveFileName() , etc. ". If you use these functions and still do not want to see the native dialog, you use the DontUseNativeDialog flag.

+6
source share

Are you sure that such a child is created? Because if so, I would suggest that you can do something like

 QString path = QFileDialog::getExistingDirectory(this, ...); QFileDialog *filedialog = this->findChild<QFileDialog*>(); if (filedialog) { filedialog->deleteLater(); } 

But I tried creating a dialog with this as the parent and calling findChild in this object, and also creating a dialogue using 0 as the parent and calling findChild in the main window; both to no avail.

0
source share
 m_filedialog->setAttribute(Qt::WA_DeleteOnClose); 
-3
source share

All Articles