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.
we use QWSServer::setCursorVisible(false) to hide the cursor in qt 4.8 , which function in qt5?
A MouseArea is an invisible item that is typically used in conjunction with a visible item in order to provide mouse handling for that item. By effectively acting as a proxy, the logic for mouse handling can be contained within a MouseArea item.
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.
you should include QCursor into main.cpp and call
QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With