can the Open File dialog be used to select a Folder?

前端 未结 2 1438
离开以前
离开以前 2020-12-23 18:44

The \"Browse For Folder\" Windows dialog is very inconvenient because:

  • it has no Path box where I can paste the path I want (eg from Total Commander)
2条回答
  •  轮回少年
    2020-12-23 19:42

    You can try this one:

    QString QFileDialog::getExistingDirectory ( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), Options options = ShowDirsOnly ) [static]
    

    This one is used to choose a directory, and will popup a dialog like you show at last.

    Demo:

     QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
                                                 "/home",
                                                 QFileDialog::ShowDirsOnly
                                                 | QFileDialog::DontResolveSymlinks);
    

提交回复
热议问题