I wonder how to hide cursor in QML, QT 5.7.
I tried to use
QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
and
app.setOverrideCursor( QCursor( Qt::BlankCursor ) );
But both doesn't work.
/home/QTProjects/main.cpp:13: error: invalid use of incomplete type 'class QCursor'
QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
^
And if it possible can I hide cursor within QML not on C++ side.
You can use a disabled overlay MouseArea
to hide it:
Button {
onClicked: console.log("clicked")
}
MouseArea {
anchors.fill: parent
enabled: false
cursorShape: Qt.BlankCursor
}
Just put the mouse area in the bottom of your main.qml
, it will be transparent to events but still override the cursor shape.
你应该将QCursor包含在main.cpp中并调用
QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.