[Moved] MouseArea/Loader Question



  • Hi I just recently noticed this error... why is it that , let's say, when we load a form and click on the area that a MouseArea has been in that position.. still works?

    I put a "Back" button at the bottom of our screen and it just so happened that when i clicked on that area the "back" button works

    thanks guys



  • Could you please make your question clearer? As for the MouseArea/Loader, Qt documentation is very clear with the following example description:

    For example, the following application.qml loads KeyReader.qml when the MouseArea is clicked.

    @
    //application.qml
    import QtQuick 1.0

    Rectangle {
    width: 200; height: 200

     Loader {
         id: loader
         focus: true
     }
    
     MouseArea {
         anchors.fill: parent
         onClicked: loader.source = "KeyReader.qml"
     }
    
     Keys.onPressed: {
         console.log("Captured:", event.text);
     }
    

    }@



  • [quote author="changsheng230" date="1310632341"]

    @
    Keys.onPressed: {
    console.log("Captured:", event.text);
    }
    }@[/quote]

    what's this for??



  • @
    onClicked: { MouseArea = false;
    AnimatedImage.visible = false;
    exit.visible = false;
    mainLoader.source = "sample.qml";}@

    Try putting bool on your on click statement like the code shown above



  • I still dont get it

    this is my codes
    apparently in my main.qml

    i have this

    @ Image{
    id:background
    width: parent.width;height: parent.height
    opacity: 0.0001
    source: "image/sizeoftouchscreen.jpg"
    MouseArea {
    id: menuClicked
    anchors.fill: parent
    onClicked: {
    MouseArea = false
    pageLoader.source="menu.qml"
    }

    }@
    

    this will call another qml file that has this code

    @ Image{
    source: "image/play.png"
    width: 181
    height: 76
    fillMode: Image.PreserveAspectCrop
    MouseArea{
    id:play
    anchors.fill: parent
    onClicked:pageLoader.source="luzon.qml"
    }
    }
    Image{
    width: 181
    height: 76
    fillMode: Image.PreserveAspectCrop
    source: "image/setting.png"
    }
    Image{
    width: 181
    height: 76
    fillMode: Image.PreserveAspectCrop
    source: "image/exit.png"
    MouseArea{
    id:exit
    anchors.fill: parent
    onClicked:{
    MouseArea = false
    AnimatedImage.visible=false
    Qt.quit()
    }
    }
    }@

    now after clicking on the PlayIcon.. it will call the main game.
    if you try to click on the area where the exit icon has been placed, it still works...
    the game exits.. any idea guys?


  • Moderators

    If you have a Loader which is loading a QML file and covering your current page (the one with the MouseAreas) and if the QML being loaded doesn't capture all mouse clicks itself, the clicks will propagate down to any active MouseArea which is "hidden" by the loaded component.

    If you put an empty MouseArea the size of your screen at the root of your loaded QML, then it will eat any extra mouse events and not pass them back down through the stack of hidden components.



  • so how will i do it? is there any possible means of loading another qml file without overlaying the previous one?? my game involves many levels of which will took place on different areas and different format of game..


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.