QtQuick 自定义信号与使用
实例简述
在界面上添加两个按钮和一个text文本,点击按钮切换文本字体颜色,此处通过自定义信号来实现(在上一节基础上添加按钮)
实例效果
实例代码
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
Rectangle {
id: window
visible: true
width: 800
height: 600
color: Qt.rgba(0.5,0.5,0.5,0.6)
MouseArea {
id: dragRegion
anchors.fill: parent
property point clickPos: "0,0"
onPressed: {
clickPos = Qt.point(mouse.x, mouse.y)
}
onPositionChanged: {
//鼠标偏移量
var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y)
//如果mainwindow继承自QWidget(用setPos)
mainwindow.setX(mainwindow.x + delta.x)
mainwind