QFileDialog::setSidebarUrls() not working
I am trying to customize sidebars URLs in a non-native file dialog but I couldn't manage it. This is the code:
QFileDialog *m_dialog = new QFileDialog(0, Qt::WindowStaysOnTopHint); QList<QUrl> urls; urls << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).front()) << QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::DesktopLocation).front()); m_dialog->setSidebarUrls(urls); m_dialog->show();
The file dialog is displayed but the sidebars URLs are the default ones. I know the QUrl objects in the list are OK because I used them with QDesktopServices::openUrl() and everything was fine.
After setting the new URLs, the method
QFileDialog::sidebarUrls()returns an empty QList<QUrl>.
I have tested this code with Qt 5.3.2 and on both Windows and Mac.
What am I doing wrong?
Current workaround: call
I do not see why do you think you use non-native dialog from the code.
"By default, a platform-native file dialog will be used if the platform has one."
And there is no proper option set.