1. 程式人生 > >QFileDialog如何選擇多個檔案

QFileDialog如何選擇多個檔案

   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: [email protected]

author:wsh