Hi Qt gurus

I am using a main List View to list/switch between 3 separate pages.
Each page is defined by its own .qml file.
In the main List View I use the keyboard up/down arrows to highlight an 
item  then press RETURN to load that list item's page (qml file) using 
Loader.
Each loaded page defines a mouse area in order to return back to the 
main List View. Everything works fine, however, I'm having difficulty 
getting the keyboard controls ( the up/down arrows and return key) 
working when I return back to the main List View. They work initially 
before I load a page.
What am I doing wrong? Is there a better way of doing this?

Here is the MainList.qml . . .

import  Qt  4.7

Rectangle  {

     id:  mainMenuScreen

     width:  640;  height:  480

     color:  "lightyellow"

     Loader  {  id:  uiLoader  }

     Item  {

         id:  textBlock

         anchors.fill:  parent

         Text  {

             anchors.top:  parent.top;  anchors.horizontalCenter:  
parent.horizontalCenter

             text:  "MAIN  LIST"

             font.pointSize:  30

         }

         ListView  {

             id:  mainListView

             focus:  true

             x:  121;  y:  140;  width:  400;  height:  200

             model:  mainListModel

             delegate:  myDelegate

             highlight:  myHighlight

             spacing:  10

         }

         ListModel  {

             id:  mainListModel

             ListElement  {  menuName:  "List1"}

             ListElement  {  menuName:  "List2"}

             ListElement  {  menuName:  "List3"}

         }

         Component  {

             id:  myDelegate

             Item  {

                 id:  wrapper

                 width:  mainListText.width;  height:  mainListText.height

                 Text  {  id:  mainListText;  text:  menuName;  }

                 Keys.onReturnPressed:  {

                     if  (menuName=="List1")

                     {uiLoader.source  =  "List1.qml";  textBlock.visible  =  
false}

                     if  (menuName=="List2")

                     {uiLoader.source  =  "List2.qml";  textBlock.visible  =  
false}

                     if  (menuName=="List3")

                     {uiLoader.source  =  "List3.qml";  textBlock.visible  =  
false}

                 }

             }

         }

         Component  {

             id:  myHighlight

             Rectangle  {

                 color:  "orange"

                 width:  mainListView.currentItem.width

                 height:  mainListView.currentItem.height

             }

         }

     }

}


And here is an example of one of the pages, List1.qml . . .

import  Qt  4.7

Rectangle  {

     width:  640;  height:  480

     color:  "lightblue"

     Loader  {  id:  uiLoader}

     Item  {

         id:list1

         anchors.fill:  parent

         Text  {

             anchors.top:  parent.top;  anchors.horizontalCenter:  
parent.horizontalCenter

             text:  "LIST  1"

             font.pointSize:  30

         }

         Text  {

             anchors.left:  parent.left;  anchors.bottom:  parent.bottom

             text:  "Main  List"

             MouseArea  {

                 anchors.fill:  parent

                 onClicked:  {uiLoader.source  =  "MainList.qml";  
list1.visible  =  false  }

             }

         }

     }

}


Many thanks

Paul Isaacs
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to