2016-11-26 91 views
2

我想知道如何在QML 5.7中隱藏遊標。如何在QML中隱藏遊標

我試圖用

QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor)); 

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

但兩者不能正常工作。

/home/QTProjects/main.cpp:13: error: invalid use of incomplete type 'class QCursor' 
    QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor)); 
                  ^

如果可能的話,我可以將光標隱藏在QML中,而不是在C++端。

+0

''#include '這樣你就可以在你的'main.cpp'中使用你的第一個代碼 – GrecKo

回答

5

您可以使用禁用覆蓋MouseArea來隱藏它:

Button { 
    onClicked: console.log("clicked") 
    } 

    MouseArea { 
    anchors.fill: parent 
    enabled: false 
    cursorShape: Qt.BlankCursor 
    } 

只要把鼠標區域在main.qml的底部,這將是透明的事件,但仍然覆蓋光標形狀。

+0

只有當我移動鼠標時才起作用,當應用程序在左上角開始時我仍然可以看到它(Raspberry Pi) – Boy