Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Change propery value inside custom style
Qt 6.11 is out! See what's new in the release blog

Change propery value inside custom style

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.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.
  • C Offline
    C Offline
    cristeab
    wrote on last edited by
    #1

    Hi

    I am trying to reuse a custom ComboBoxStyle by changing the text displayed when the combo box is empty. In a separate file, CustomComboStyle.qml I have the following definition:
    @
    Component {
    ComboBoxStyle {
    label: Item {
    anchors.fill: parent
    Text {
    text: (-1 == control.currentIndex)?qsTr("Choose a task..."):control.textAt(control.currentIndex)
    }
    }
    }
    }
    @

    I need when instantiating this style to change also the text shown when currentIndex is -1. Currently I have no solution for this as properties declared inside Component are not supported, so I need to have different files just with the above text changed. Is there a more elegant solution ?

    [edit: Added coding tags @ SGaist]

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cristeab
      wrote on last edited by
      #2

      I have found that a possible solution is to define a custom ComboBox in a separate file with the ComboBoxStyle defined inside, then properties can be defined in the ComboBox for controlling style behavior.

      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