How can I disable Mouse Clicks in certain MouseAreas?

I am using the some code inside MouseArea{ .... } and want them to be disabled till the time a flag for them doesn't turn TRUE!

onClicked: {
                focus: true
                onClicked: pageLoader.source = "PAGE3.qml";
           }

There are multiple mouseAreas in the program. What is needed is to disable all other MouseAreas when one MouseArea has already been clicked and the page corresponding to that mouseArea is loaded using loader .
These mouseAreas are loaded as a matrix using the Grid function of QML.

How can I do that?

有帮助吗?

解决方案 2

Got the answer! You need to add
enable: false

Example:
Grid {
enable: true }

This will enable the Grid and;

Grid {
enable: false }

This will disable the Grid!

其他提示

Something like this?

import QtQuick 2.1

Rectangle {
    width: 800
    height: 600
    property bool clickable
    MouseArea {
            anchors.fill:parent
            onClicked: {
                    if (clickable)
                            console.log("clicked");
                    else 
                            console.log("unclickable");

            }
    }
    Component.onCompleted: clickable = true;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top