Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileDialog::setSidebarUrls() not working
Forum Updated to NodeBB v4.3 + New Features

QFileDialog::setSidebarUrls() not working

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cesius
    wrote on last edited by
    #1

    Hi everyone,

    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?

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Current workaround: call setOption(QFileDialog::DontUseNativeDialog); before setSidebarUrls

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alex_malyu
        wrote on last edited by
        #3

        @Cesius said:

        QFileDialog

        I do not see why do you think you use non-native dialog from the code.

        From documentation:
        "By default, a platform-native file dialog will be used if the platform has one."

        And there is no proper option set.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved