July 7, 2012

bluestreak bluestreak
Lab Rat
33 posts

QML state changes on double click

 

Hi all,

I am trying to build a touch screen of tabs, which when the central part of the screen in double clicked on, goes to a new state where there are two identical tab displays up instead of only seeing one. However, this never seems to happen. Can anyone see something wrong with this implementation?

  1. import QtQuick 1.1
  2.  
  3. Item {
  4.     width: 1540
  5.     height: 320
  6.     MouseArea{
  7.         id: mouseArea
  8.         x: 0
  9.         y: 58
  10.         width: 1540
  11.         height: 262
  12.         anchors.rightMargin: 0
  13.         anchors.bottomMargin: 0
  14.         anchors.leftMargin: 0
  15.         anchors.topMargin: 58
  16.         anchors.fill: parent
  17.     }
  18.  
  19.     Tabs {
  20.         width: 1540
  21.         height: 320
  22.         id: tabs
  23.  
  24.     }
  25.  
  26.     Tabs {
  27.         id: tabs1
  28.         x: 0
  29.         y: 0
  30.         width: 770
  31.         height: 320
  32.     }
  33.  
  34.  
  35.     states: [
  36.         State {
  37.             name: "State1"; when: mouseArea.doubleClicked
  38.             PropertyChanges {
  39.                 target: tabs
  40.                 width: 770
  41.                 height: 320
  42.             }
  43.  
  44.             PropertyChanges {
  45.                 target: tabs1
  46.                 x: 770
  47.                 y: 0
  48.                 width: 770
  49.                 height: 320
  50.             }
  51.         }
  52.     ]
  53. }

2 replies

July 7, 2012

bluestreak bluestreak
Lab Rat
33 posts

For anyone interested, I was able to fix this by using onDoubleClicked within the mouseArea tag, and then having that change a property bool. Using mouseArea.doubleClicked like above doesn’t work. Solution:

  1.  property bool twoScreens: false
  2.     MouseArea{
  3.         id: mouseArea
  4.         onDoubleClicked: twoScreens = !twoScreens
  5.     }
  6.     states: [
  7.         State {
  8.             name: "State1"; when: twoScreens

July 9, 2012

chriadam chriadam
Ant Farmer
181 posts

The reason is that “doubleClicked” is a signal, not a property. The “when” property of a State, is of type Binding which expects the result of the binding expression to be boolean.

 
  ‹‹ MouseArea pressedButtons      Basic Form Layout for Symbian in QML ››

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