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. Set ComboBox text to something not in model
Forum Updated to NodeBB v4.3 + New Features

Set ComboBox text to something not in model

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlcombobox
2 Posts 2 Posters 1.3k Views 2 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.
  • P Offline
    P Offline
    PhTe
    wrote on last edited by
    #1

    Hi,
    i have a QML file with a ComboBox in it.

    ....
    ComboBox {
                    id: searchForComboBox
                    objectName: "searchFor"
                    anchors.margins: 2
                    currentIndex:  0
                    editable: true
                    clip: true
                    model: searchComboBoxModel
                    width: 200
                    editText: "abc" // <-- Problem here
                }
    ....
    

    I need to set the text in the box to something that is not in the model. It should be used to indicate that nothing was selected in the combobox.
    I tried the 'editText' property, but it seems it will be ignored. My combobox always selects the first model item on startup.

    1 Reply Last reply
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by jpnurmi
      #2

      With Qt Quick Controls 2, you can set ComboBox::displayText to anything you like: http://doc-snapshots.qt.io/qt5-5.7/qml-qtquick-controls2-combobox.html#displayText-prop

      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