QT開啟檔案

2021-08-15 01:17:13 字數 1172 閱讀 4001

這裡我們使用qt中的qfiledialog類。

查詢幫助文件,呼叫函式

qstring

qfiledialog::

getopenfilename

(qwidget

*parent

= q_nullptr, const 

qstring

&caption

= qstring(), const 

qstring

&dir

= qstring(), const 

qstring

&filter

= qstring(), 

qstring

*selectedfilter

= q_nullptr, 

options

options

= options())

例子:

第乙個引數為this指標,第二個為標題欄題目,第三個為路徑,第四個為型別檔案。

the file dialog's working directory will be set to dir. if dir includes a file name, the file will be selected. only files that match the given filter are shown. the filter selected is set to selectedfilter. the parameters dir, selectedfilter, and filter may be empty strings. if you want multiple filters, separate them with ';;', for example:

"images (*.png *.xpm *.jpg);;text files (*.txt);;xml files (*.xml)"

注: 

中文標題可以使用函式qstring::fromlocal8bit();

Qt 無法開啟輸入檔案 obj

給乙個專案刪除一些舊 檔案 新增一些新 檔案後重新編譯,莫名其妙報這個錯誤 link1118 無法開啟輸入檔案xx xx obj 第一反應我是懵的,這什麼東西,檔名都沒有。去查了一下makefile檔案,qt debug模式的makefile檔案是makefile.debug。發現生成的物件obje...

Qt程式設計呼叫外部程式開啟檔案

qdesktopservices openurl qurl fromlocalfile filename filename 檔名,如c 新建 microsoft word 文件.doc qurl fromlocalfile 一定要用這個方法,因為檔名或路徑中中文或空格,不然打不開檔案.直接用qurl...

Qt中呼叫外部程式開啟檔案

qdesktopservices openurl qurl fromlocalfile filename filename 檔名,如c 新建 microsoft word 文件.doc qurl fromlocalfile 一定要用這個方法,因為檔名或路徑中中文或空格,不然打不開檔案.直接用qurl...