PDA

View Full Version : QListWidget custom numbering ?



pshah.mumbai
11th July 2008, 19:23
http://doc.trolltech.com/4.4/qlistwidget.html

The items are always numbered from 0

Is it possible to add a custom number/string rather than the ones provided by default ?

Something similar to the select statement in HTML ?

:confused:

jacek
12th July 2008, 01:21
Do you mean that you would like to pass something different than 0-based index to QListWidget::item()?

pshah.mumbai
12th July 2008, 08:11
<select>
<option value="A001">Alanka</option>
..

I want do something that is similar to a select option in html. It allows the programmer to specify their own index values.

this too applies for qcombobox.

It only allows int index starting from 0.

Is it possible ?

jacek
12th July 2008, 14:22
You can use two QMaps to translate indices to keys and vice versa.

pshah.mumbai
14th July 2008, 13:43
I will have to create a seperate map that links the model index values with ids comings from database ?

The combobox i want to use is linked with a db. with one tables ids, name

I want to show the name in the combo box and the ids as the index value.

i will have to create a seperate map that links the ids with the int. index of combo box and call the function does that everytime the underlying model changes ?

wysota
14th July 2008, 15:29
You can use QComboBox::setItemData() to make a mapping. I'm not sure what does it have to do with QListWidget...