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. How to refer to a value in a text in QML List Element
Qt 6.11 is out! See what's new in the release blog

How to refer to a value in a text in QML List Element

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 906 Views
  • 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.
  • mamoudM Offline
    mamoudM Offline
    mamoud
    wrote on last edited by
    #1

    Hi,
    I have a list element like this:

        ListElement {
            type: "boolean"
            label: "Change the option"
            func3text: "OFF"
            func3subtext: "The change is disabled"
            func4text: "ON"
            func4subtext: "The change is enabled for  (some value)"
            target: "value"
        }
    

    How can I write
    func4subtext: ("The change is enabled for %d", value)

    as we write in C++, to refer to a changing value in a text

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      I don't think you will be able to do like this. Based on some condition get the existing values using get(..) method and set value back. This is the only option I feel.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      1 Reply Last reply
      0
      • mamoudM Offline
        mamoudM Offline
        mamoud
        wrote on last edited by mamoud
        #3

        Thank you!
        How can get() method be used,?

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
          wrote on last edited by dheerendra
          #4

          var el = id.get(index) where id is identity property of model object. Refer Qt Assistant as well.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          https://www.pthinks.com

          1 Reply Last reply
          3
          • mamoudM Offline
            mamoudM Offline
            mamoud
            wrote on last edited by
            #5

            Alright!
            Solved, thank you!

            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