您好,登錄后才能下訂單哦!
這篇文章主要介紹“Qt6基于Qml的文件對(duì)話框效果怎么實(shí)現(xiàn)”的相關(guān)知識(shí),小編通過(guò)實(shí)際案例向大家展示操作過(guò)程,操作方法簡(jiǎn)單快捷,實(shí)用性強(qiáng),希望這篇“Qt6基于Qml的文件對(duì)話框效果怎么實(shí)現(xiàn)”文章能幫助大家解決問(wèn)題。
主界面如下
打開(kāi)單個(gè)文件配置
FileDialog { id: idFileOpenOne fileMode: FileDialog.OpenFile nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] options :FileDialog.ReadOnly }
打開(kāi)多個(gè)文件配置
FileDialog { id: idFileOpenMore fileMode: FileDialog.OpenFiles nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] options :FileDialog.ReadOnly }
保存文件配置
FileDialog { id: idFileSave nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] fileMode: FileDialog.SaveFile }
三個(gè)按鈕布局
Row{ anchors.centerIn: parent spacing: 30 Button{ text: qsTr("Open") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileOpenOne.open(); } } } Button{ text: qsTr("Open More ...") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileOpenMore.open(); } } } Button{ text: qsTr("Save") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileSave.open(); } } } }
點(diǎn)擊效果展示:
完整源碼:
import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import Qt.labs.platform 1.1 ApplicationWindow { visible: true width: 600 height: 200 title: qsTr("Qt6基于Qml的文件對(duì)話框演示") Row{ anchors.centerIn: parent spacing: 30 Button{ text: qsTr("Open") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileOpenOne.open(); } } } Button{ text: qsTr("Open More ...") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileOpenMore.open(); } } } Button{ text: qsTr("Save") height: 48 width: 120 MouseArea{ anchors.fill: parent onClicked: { idFileSave.open(); } } } } FileDialog { id: idFileOpenOne fileMode: FileDialog.OpenFile nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] options :FileDialog.ReadOnly } FileDialog { id: idFileOpenMore fileMode: FileDialog.OpenFiles nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] options :FileDialog.ReadOnly } FileDialog { id: idFileSave nameFilters: ["Pictures (*.png *.jpg *.gif *.bmp)", "All (*.*)"] fileMode: FileDialog.SaveFile } }
關(guān)于“Qt6基于Qml的文件對(duì)話框效果怎么實(shí)現(xiàn)”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí),可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會(huì)為大家更新不同的知識(shí)點(diǎn)。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。