Qt之MenuBar

Qt之MenuBarimportQtQuic 6importQtQui Controls1 2importQtQui Window2 2importQtQui Layouts1 1Application id namewidth 640height 480visible truetitle qsTr he

import QtQuick 2.6 import QtQuick.Controls 1.2 import QtQuick.Window 2.2 import QtQuick.Layouts 1.1 ApplicationWindow { // id: name width: 640 height: 480 visible: true title:qsTr("hello World"); /* // Text { // width: 100; // height: 100; text:msg.author // } // Loader{ // anchors.fill: parent; // sourceComponent: rect; // } // Component{ // id:rect; // Rectangle{ // width: 50; // height: 50; // color:'red' // } // } */ Action{ id:quitAction text:qsTr("Quit"); shortcut: "ctrl+Q"; onTriggered: Qt.quit() } Action{ id:cutAction;text:qsTr("Cut"); shortcut: "ctrl+X"; onTriggered: Qt.quit() } Action{ id:copyAction;text:qsTr("Copy"); shortcut: "Ctrl+C"; onTriggered: Qt.quit() } Action{ id:pasteAction; text:qsTr("Paste"); shortcut: "Ctrl+P"; onTriggered: Qt.quit() } menuBar: MenuBar{ Menu{ title: qsTr("File") MenuItem{ text:"open" action: quitAction } } Menu{ title: qsTr("Edit") MenuItem { text:"剪切" action:cutAction } MenuItem { text:"复制" action:copyAction } MenuItem { text:"粘贴" action:pasteAction } } } toolBar: ToolBar{ id:mainToolBar width:parent.width Row{ anchors.fill: parent ToolButton{action:cutAction} ToolButton{action:copyAction} ToolButton{action:pasteAction} } } Button{ text:qsTr("Hello World"); anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter } }
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/227598.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月16日 下午8:57
下一篇 2026年3月16日 下午8:57


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号