[Qt-interest] Select index of comboBox with item Data (ID)
Matthias Pospiech
matthias.pospiech at gmx.de
Wed Jun 30 09:25:21 CEST 2010
Malyushytsky, Alex schrieb:
>>> but would help developers avoid writing the same code every time they want to select an item with specific data.
>>>
>
> What you are going to save?
>
> Typing few characters:
> combo->setCurrentIndex( combo->findData(data, role, flags) );
> vs
> combo->selectItem( data, role, flags );
>
To me the number of character is not what is important for such a decision.
Qt has a select-by-ID feature in other widgets like for example in
QButtonGroup.
This is really helpful, because one can apply values from an enum and
set and select using these enum values.
A QButtonGroup however is not useful for an enum list with 5+ items. In
this case I switch to a
QComboBox for selection. However it is not obvious how to achieve the
same approach with a QComboBox.
This could be solved by adding functions like meantioned above and
adding information to the docs.
Matthias
More information about the Qt-interest-old
mailing list