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. Reset custom property value.
Forum Updated to NodeBB v4.3 + New Features

Reset custom property value.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 267 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.
  • E Offline
    E Offline
    Ekta
    wrote on last edited by Ekta
    #1

    Hello,
    I have a Button & Text. The Button has a toggle property when we click on it, acts like a toggle & displays the whole text message and off displays just one line with ...
    My question is, is there any way to reset this value to controller.toggle if needed?
    Switching back and forth to this qml component just takes the last value of toggle instead of resetting it to controller's value.

    Initially, I tried to set checkable to be true and used checked: controller.toggle and it worked but problem is screen reader reads it as checkbox instead of a button

      Text {
            id: textbox
    
            maximumLineCount: toggleBtn.toggle ? 2 : 1
            elide: Text.ElideRight
            wrapMode: Text.WordWrap
            textFormat: Text.StyledText
            text: controller.messageText
    }
    Button {
            id: toggleBtn
           property bool toggle: controller.toggle
    
            height: 24
            width: 24
            focus: visible
            visible: textBox.truncated || toggle
           iconName: toggle ? "arrow-up" : "arrow-down"
            onClicked: {
                toggle = !toggle;
                controller.onExpand(toggle);
            }
    }
    
    1 Reply Last reply
    0
    • N Offline
      N Offline
      NYBL
      wrote on last edited by NYBL
      #2

      Why you do toggle = !toggle; and not controller.toggle = !toggle;
      also why you call controller.onExpand(toggle); in qml and not in the toggle setter?

      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