main.qml
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
ApplicationWindow {
id: rootWindow
visible: true
width: 640
height: 480
title: qsTr("Hello World")
flags: Qt.Window | Qt.FramelessWindowHint
property point dragStart
property bool dragActive: false
// 引入自定义标题栏部件
TitleBar {
id: titleBar
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
window: rootWindow
}
}
TitleBar.qml
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Window 2.0
Item {
id: titleBar
height: 40
property Window window
Rectangle {
width: parent.width
height: parent.height
color: "black"
border.color: "red"
}
Text {
id: titleText
text: window.title
anchors.verticalCenter: parent.verticalCenter

最低0.47元/天 解锁文章
518

被折叠的 条评论
为什么被折叠?



