您的位置:首页 > 编程语言 > Qt开发

QFileDialog如何选择多个文件

2016-09-17 09:03 337 查看
   QFileDialog 按说是默认选择多个文件,但是我的ctrl 和shift键都不管用,每次只能选择一个文件,很惆怅....

   网上大部分都是问如何选择多个文件和文件夹的.后来发现:

 

add_file_dialog->setFileMode(QFileDialog::ExistingFiles);

  

  是设置选择多个文件的,  请注意和以下语句的区别

add_file_dialog->setFileMode(QFileDialog::ExistingFile);

enum QFileDialog::FileMode
This enum is used to indicate what the user may select in the file dialog; i.e. what the dialog will return if the user clicks OK.

Constant Value Description
QFileDialog::AnyFile 0 The name of a file, whether it exists or not.
QFileDialog::ExistingFile 1 The name of a single existing file.
QFileDialog::Directory 2 The name of a directory. Both files and directories are displayed.
QFileDialog::ExistingFiles 3 The names of zero or more existing files.

email: tongzhuodenilove@163.com

author:wsh
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  qt5