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. QML state changes on double click
Forum Updated to NodeBB v4.3 + New Features

QML state changes on double click

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 5.2k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    bluestreak
    wrote on last edited by
    #1

    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?

    @
    import QtQuick 1.1

    Item {
    width: 1540
    height: 320
    MouseArea{
    id: mouseArea
    x: 0
    y: 58
    width: 1540
    height: 262
    anchors.rightMargin: 0
    anchors.bottomMargin: 0
    anchors.leftMargin: 0
    anchors.topMargin: 58
    anchors.fill: parent
    }

    Tabs {
        width: 1540
        height: 320
        id: tabs
    
    }
    
    Tabs {
        id: tabs1
        x: 0
        y: 0
        width: 770
        height: 320
    }
    
    
    states: [
        State {
            name: "State1"; when: mouseArea.doubleClicked
            PropertyChanges {
                target: tabs
                width: 770
                height: 320
            }
    
            PropertyChanges {
                target: tabs1
                x: 770
                y: 0
                width: 770
                height: 320
            }
        }
    ]
    

    }
    @

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bluestreak
      wrote on last edited by
      #2

      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:
      @
      property bool twoScreens: false
      MouseArea{
      id: mouseArea
      onDoubleClicked: twoScreens = !twoScreens
      }
      states: [
      State {
      name: "State1"; when: twoScreens
      @

      1 Reply Last reply
      1
      • C Offline
        C Offline
        chriadam
        wrote on last edited by
        #3

        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.

        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