June 22, 2011

eirnanG eirnanG
Lab Rat
23 posts

Overlapping QML

 

  1.  //choose2chiuaua.qml
  2.  
  3. import QtQuick 1.0
  4.  
  5. Rectangle {
  6.     width: choose_chiuaua.width; height: choose_chiuaua.height
  7.  
  8.    Loader {
  9.    id: mainLoader
  10.    anchors.fill: parent
  11.  
  12.    MouseArea {
  13.        id: cchoose2menu
  14.        x: 162
  15.        y: 272
  16.        width: 78
  17.        height: 44
  18.        onClicked:  {mainLoader.source = "menu.qml";}
  19.    }
  20.  
  21.    MouseArea {
  22.        id: cchoose2name
  23.        x: 0
  24.        y: 272
  25.        width: 78
  26.        height: 44
  27.        onClicked:  {mainLoader.source = "naming_pet.qml";}
  28.    }
  29.  
  30.    MouseArea {
  31.        id: chiuaua_next
  32.        x: 191
  33.        y: 178
  34.        width: 43
  35.        height: 44
  36.        onClicked:  {mainLoader.source = "choose2shitzu.qml";}
  37.  
  38.    }
  39.  
  40.    MouseArea {
  41.        id: chiuaua_back
  42.        x: 12
  43.        y: 179
  44.        width: 43
  45.        height: 44
  46.        onClicked:  {mainLoader.source = "choose2aspin.qml";}
  47.  
  48.    }
  49.  
  50.    AnimatedImage { id: choose_chiuaua; x: 0; y: 0; width: 240; height: 316;
  51.        source: "Choose Pet (Chiuaua)" } // GIF FILE
  52.     }
  53. }

  1. // choose2aspin.qml
  2.  
  3. import QtQuick 1.0
  4.  
  5. Rectangle {
  6.     width: choose_aspin.width; height: choose_aspin.height
  7.  
  8.    Loader {
  9.    id: mainLoader
  10.    anchors.fill: parent
  11.  
  12.    MouseArea {
  13.        id: achoose2menu
  14.        x: 162
  15.        y: 272
  16.        width: 78
  17.        height: 44
  18.        onClicked:  {mainLoader.source = "menu.qml";}
  19.    }
  20.  
  21.    MouseArea {
  22.        id: achoose2name
  23.        x: 0
  24.        y: 272
  25.        width: 78
  26.        height: 44
  27.        onClicked:  {mainLoader.source = "naming_pet.qml";}
  28.    }
  29.  
  30.    MouseArea {
  31.        id: aspin_next
  32.        x: 191
  33.        y: 178
  34.        width: 43
  35.        height: 44
  36.        onClicked:  {mainLoader.source = "choose2chiuaua.qml";}
  37.    }
  38.  
  39.    MouseArea {
  40.        id: aspin_back
  41.        x: 12
  42.        y: 179
  43.        width: 43
  44.        height: 44
  45.        onClicked:  {mainLoader.source = "choose2shitzu.qml";}
  46.  
  47.    }
  48.  
  49.    AnimatedImage { id: choose_aspin; x: 0; y: 0; width: 240; height: 316;
  50.        source: "Choose Pet (Aspin)" } //GIF FILE
  51.  }
  52. }

  1. //choose2shitzu.qml
  2.  
  3. import QtQuick 1.0
  4.  
  5. Rectangle {
  6.     width: choose_shitzu.width; height: choose_shitzu.height
  7.  
  8.    Loader {
  9.    id: mainLoader
  10.    anchors.fill: parent
  11.  
  12.    MouseArea {
  13.        id: schoose2menu
  14.        x: 162
  15.        y: 272
  16.        width: 78
  17.        height: 44
  18.        onClicked:  {mainLoader.source = "menu.qml";}
  19.    }
  20.  
  21.    MouseArea {
  22.        id: schoose2name
  23.        x: 0
  24.        y: 272
  25.        width: 78
  26.        height: 44
  27.        onClicked:  {mainLoader.source = "naming_pet.qml";}
  28.    }
  29.  
  30.    MouseArea {
  31.        id: shitzu_next
  32.        x: 191
  33.        y: 178
  34.        width: 43
  35.        height: 44
  36.        onClicked:  {mainLoader.source = "choose2aspin.qml";}
  37.  
  38.    }
  39.  
  40.    MouseArea {
  41.        id: shitzu_back
  42.        x: 12
  43.        y: 179
  44.        width: 43
  45.        height: 44
  46.        onClicked:  {mainLoader.source = "choose2chiuaua.qml";}
  47.  
  48.    }
  49.  
  50.    AnimatedImage { id: choose_shitzu; x: 0; y: 0; width: 240; height: 316;
  51.        source: "Choose Pet (Shih Tzu)" }
  52.  
  53.  
  54.  
  55.     }
  56.  
  57. }

Hi to all!

Here are some of my codes in QML. Its working and the MouseArea(s) are working too. But the thing is, its only overlapping the previous QML and the previous MouseArea(s) is still in the new called QML.

Please help me. Thanks in Advance

EDIT: moved to forum Qt Quick, Gerolf

7 replies

June 22, 2011

TobbY TobbY
Lab Rat
209 posts

i think, you have to close the previous qml.

 Signature 

Code Code Code

June 22, 2011

eirnanG eirnanG
Lab Rat
23 posts

im trying.. and im still looking for a code to close the previous qml.. but i failed.. :(

June 22, 2011

Vijay Bhaska Reddy Vijay Bhaska Reddy
Lab Rat
399 posts

eirnanG wrote:
  1.  //choose2chiuaua.qml
  2.  
  3. Here are some of my codes in QML. Its working and the MouseArea(s) are working too. But the thing is, its only overlapping the previous QML and the previous MouseArea(s) is still in the new called QML.
  4.  
  5. Please help me. Thanks in Advance</blockquote>
  6.        
  7. Your previous MoseArea(s) will still be active as your are not making then invisible or reducing the size to zero.
  8.  
  9. @http://doc.qt.nokia.com/4.7-snapshot/qml-loader.html#source-prop

According to the doc, setting new source should unload previous item and load the new one. If this does not happen then its a bug.

}

June 22, 2011

cmer4 cmer4
Lab Rat
111 posts

Maybe try adding the enabled property to the MouseAreas or to the Loader and then enabled: false the once you don’t need??
Not sure if it works with those elements though…

June 22, 2011

eirnanG eirnanG
Lab Rat
23 posts

cmer4 and Vijay thanks!! it works..
it makes me enjoy more in using QT :)

June 22, 2011

Vijay Bhaska Reddy Vijay Bhaska Reddy
Lab Rat
399 posts

you are welcome. So only thing you did was making MouseArea disabled when you don’t need them?

June 22, 2011

eirnanG eirnanG
Lab Rat
23 posts

yea.. it helps a lot, because we’re using almost 20 QMLs…. :)

 
  ‹‹ Is there a possiblity of setting InputMethodHints to TextEdit in qml      Problem changing the states when switching the current screen to next screen ››

You must log in to post a reply. Not a member yet? Register here!