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. Changing single properties of children without knowing id

Changing single properties of children without knowing id

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 388 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.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    Hi,

    I have a general question, motivated by my problem in https://forum.qt.io/topic/103394/using-subscripts-in-text-inside-combobox

    If I use e.g. a ComboBox can I change a property in the combobox's contentItem (e.g. setting textFormat = Text.RichtText) without replacing the complete contentItem? The problem is, that contentItem does not have an id which I can sue.

    sierdzioS 1 Reply Last reply
    0
    • M maxwell31

      Hi,

      I have a general question, motivated by my problem in https://forum.qt.io/topic/103394/using-subscripts-in-text-inside-combobox

      If I use e.g. a ComboBox can I change a property in the combobox's contentItem (e.g. setting textFormat = Text.RichtText) without replacing the complete contentItem? The problem is, that contentItem does not have an id which I can sue.

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You don't need an ID as long as you do have it's parent ID. Assuming that:

      SomeItem {
        id: bob
        contentItem: Text {
          textFormat: Text.RichText
        }
      }
      

      You should be able to do:

      // Some JS function
      bob.contentItem.textFormat = Text.PlainText
      

      In your case, you are attempting to modify an already displayed delegate, right? That is wrong, don't do it. Delegates are created and deleted on the fly, you should not relay on them in any way. If you need to modify the data or the way it is displayed, you should use your model for that, thus exposing data to your delegate so that it can adapt to it.

      (Z(:^

      1 Reply Last reply
      4
      • M Offline
        M Offline
        maxwell31
        wrote on last edited by maxwell31
        #3

        Yes, I am attempting to modify an already displayed delegate, setting the textFormat for a ComboBox or CheckBox. I thought if I do it in Component.onCompleted it would be OK, or not?

        Edit: I just tried your suggestion for a ComboBox, and it works perfectly, doing it insideComponent.onCompleted.

        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