Russell Sk. Russell Sk. - 1 year ago 395
C++ Question

How to hide cursor in QML

I wonder how to hide cursor in QML, QT 5.7.

I tried to use



app.setOverrideCursor( QCursor( Qt::BlankCursor ) );

But both doesn't work.

/home/QTProjects/main.cpp:13: error: invalid use of incomplete type 'class QCursor'

And if it possible can I hide cursor within QML not on C++ side.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download