Caveat about QFileDialog

Volker Krause vkrause at kde.org
Thu Nov 17 14:42:48 UTC 2011


On Wednesday 16 November 2011 18:39:57 Kevin Kofler wrote:
> Hi,
> 
> In this recent discussion:
> http://mail.kde.org/pipermail/kde-frameworks-devel/2011-November/000026.html
> it was decided to use QFileDialog instead of KFileDialog, because:
> > QFileDialog now uses the platform dialog, including the KDE one
> 
> This was executed with commits such as:
> http://commits.kde.org/kdelibs/017799ceb0c8a05d2bd3ce7d3c259529d68c6217
> 
> But the problem is: At least in Qt 4.8 (I haven't checked Qt 5 yet because
> browsing its submodules in the Gitorious interface doesn't work properly),
> only the STATIC API of QFileDialog supports platform dialogs. If you
> construct a QFileDialog OBJECT as the above commit does, you always get the
> ugly Qt-only dialog! So it's a very bad idea to do that.

Did you actually test this? Because the following simple test (based on the 
referred code) works just fine here and shows the native KDE dialog:

#include <QtGui>

int main(int argc, char** argv)
{
  QApplication app(argc, argv);
  QFileDialog dlg(0, "Select Icon", QString(), "*.png *.xpm *.svg *.svgz|Icon 
Files (*.png *.xpm *.svg *.svgz)");
  dlg.setFileMode(QFileDialog::ExistingFile);
  dlg.exec();
}

regards
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20111117/21715f2d/attachment.sig>


More information about the Kde-frameworks-devel mailing list