在工程檔案設定中修改[qt modules] 中增加xml;
加一行:qt+=xml
xml例:
把xml檔案存入utf-8格式的檔案中。(如果沒有中文字元,檔案存放格式可以忽略)
<
?xml version=
"1.0" encoding=
"utf-8"
?>
"test"
>
<
class
class_name
="english"
>
50<
/students>
a building, room2022<
/classroom>
<
/class
>
<
class
class_name
="chemistry"
>
50<
/students>
b building, room2023<
/classroom>
<
/class
>
<
/classes>
#include
// 檔案頭必須引入
void
par***ml
(qstring file_name)
qdomdocument document;
qstring error;
int row =0;
int column =0;
if(!document.
setcontent
(&file,
false
,&error,
&row,
&column))if
(document.
isnull()
) qdomelement root = document.
documentelement()
; qstring root_tag_name = root.
tagname()
;if(root.
hasattribute
("info"))
// 判斷是否有【info】屬性值
qdomelement class_element = root.
firstchildelement()
;// 取第1個子節點。
if(class_element.
isnull()
)return
; qstring tag_name = class_element.
tagname()
;// 取元素的tag名。
qstring class_name = class_element.
attributenode
("class_name").
value()
;// 取元素【class_name】屬性值
//獲取子節點
qdomnodelist list = root.
childnodes()
;int count = list.
count()
;// 獲取子節點個數
for(
int i =
0; i < count; i++)}
}
int
main
(int argc,
char
*ar**)
QT下應用程式開發
一 應用程式的編輯與編譯 從最簡單也是最著名的hello word來學習qt。首先建立helloword.cpp mkdir hello vi helloword.cpp include int main int argc,char argv cd hello 指定交叉編譯器路徑 export pa...
Qt5開發 QT概述 Qt應用程式框架
第一篇 qt概述 qt是諾基亞公司的c 視覺化開發平台。與vc 相比,qt簡單方便 功能完善 跨平台 擴充套件功能強,可用於嵌入式開發。它是乙個跨平台的c 圖形介面應用程式框架 c gui 它是完全物件導向的,很容易擴充套件,並且可應用於元件程式設計。qt分商業版和開源版,其中商業版為商業軟體提供開...
Qt 發布應用程式
qt 官方開發環境使用的動態鏈結庫方式,在發布生成的exe程式時,需要複製一大堆 dll,如果自己去複製dll,很可能丟三落四,導致exe在別的電腦裡無法正常執行。因此 qt 官方開發環境裡自帶了乙個工具 windeployqt.exe。以官方 qt 5.8.0 mingw 開發環境為例,從開始選單...