前言
程序开发中不仅需要设计好功能模块,还需要完善小细节,比如鼠标悬浮在按钮上,鼠标形状变成小手。这篇博客我就介绍一下鼠标的形状是怎么设置的。
鼠标形状设置
以下是我在Qt帮助上截取的枚举所对应的鼠标形状,调用时qml用Qt.ArrowCursor,c++用Qt::ArrowCursor。
具体的代码是
qml:一般是在鼠标事件里设置鼠标形状的(属性cursorShape)
MouseArea{
anchors.fill: parent;
//小手
cursorShape: Qt.PointingHandCursor;
hoverEnabled: true;
//进
onEntered: {
txt.font.pointSize=18;
}
//出
onExited: {
txt.font.pointSize=15;
}
}
c++:一般直接在函数setCursor里设置
ui->pushButton->setCursor(Qt::PointingHandCursor);
结束语
这一小点,记住了吗?