Thomas Banderas
Thomas Banderas

Reputation: 1739

qt combobox readable but editable

I have at QComboBox some items (added by program - it is a lot added items (about 1000))

So i make combobox editable -> then it is simple to find a correct item. (For example if i want to find item called "My Example" i write in combobox "MY" and i get items which starts from "MY" )

But when i write somethink other than it is in combobox, combobox add this item.

I dont want it, i want only to:

  1. Can select only ITEMS added by Program
  2. Block adding custom items
  3. When i write something like "MY" but dont select item "My Example" because there is "My Example","My Example2"

And press push button to accept my choice - then how to check that i choice item from items added by Program not written and not finished by User?

Upvotes: 3

Views: 2651

Answers (1)

Ezee
Ezee

Reputation: 4354

Set these QComboBox properties to the following:
1. Set setEditable to true.
2. Set insertPolicy to NoInsert.
3. Set currentIndex to -1 to make it empty at start.

Then process currentIndexChanged signal which will be sent only when a certain item from the list is chosen.

Upvotes: 7

Related Questions