Hi,
I instanciate a QComboBox with a completion mode like this
combo->setEditable(true);
combo
->completer
()->setCompletionMode
(QCompleter::PopupCompletion);
combo->setEditable(true);
combo->setInsertPolicy(QComboBox::NoInsert);
combo->completer()->setCompletionMode(QCompleter::PopupCompletion);
To copy to clipboard, switch view to plain text mode
Then I fill the combo with items like this
combo
->addItem
(QIcon("someIcon"),
"Choice A",
42);
combo
->addItem
(QIcon("someIcon"),
"Choice A",
4242);
combo
->addItem
(QIcon("someIcon"),
"Choice B",
43);
combo
->addItem
(QIcon("someIcon"),
"Choice B",
4343);
combo->addItem(QIcon("someIcon"), "Choice A", 42);
combo->addItem(QIcon("someIcon"), "Choice A", 4242);
combo->addItem(QIcon("someIcon"), "Choice B", 43);
combo->addItem(QIcon("someIcon"), "Choice B", 4343);
To copy to clipboard, switch view to plain text mode
I have duplicate choice A and B with different QVariant attached to the items.
at runtime when I use the combo with the full dropdown list, my activated() slot give me currentIndex() like this :
I select first Choice A -> currentIndex = 0
I select second Choice A -> currentIndex = 1
I select first Choice B -> currentIndex = 2
I select second Choice B -> currentIndex = 3
the problem is when I do not use the dropdown, but use the completion it give me this :
completion for first Choice A -> currentIndex = 0
completion for second Choice A -> currentIndex = 0
completion for first Choice B -> currentIndex = 2
completion for second Choice B -> currentIndex = 2
My guess is that the Completer do a findItem with the text of the completer, and then return me the first item that is named like that in the combobox, but it seems like a problem.
Does someone know why it does that ? and how can I have the right currentIndex even with completion.
Thank you
Bookmarks