Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Moved] MouseArea/Loader Question

[Moved] MouseArea/Loader Question

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 5.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lexan
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • C Offline
      C Offline
      changsheng230
      wrote on last edited by
      #2

      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);
       }
      

      }@

      Chang Sheng
      常升

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lexan
        wrote on last edited by
        #3

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

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

        what's this for??

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jr_jags
          wrote on last edited by
          #4

          @
          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

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lexan
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mlong
              wrote on last edited by
              #6

              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.

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lexan
                wrote on last edited by
                #7

                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..

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved