PDA

View Full Version : QcomboBox items



therealjag
21st March 2006, 12:06
hey there i have a QComboBox with 3 different items inside it. i basically want to select 1 of the items and then i want them to alter an integer, i. e. if selection 1 is chosen from the QComboBox then int selection = 1, if item 2 is chosen then int selection = 2 etc. i was looking at the QComboBox library but i cant find how to do this - any idea's?

zlatko
21st March 2006, 12:19
int a = cmb->currentIndex () + 1;

therealjag
21st March 2006, 13:04
hey there where do i stick that code? do i put it in a seperate function as a slot or in the constructor of the QComboBox?

jpn
21st March 2006, 13:12
... Where would you use that int selection? Put the example piece of code there and replace cmb with the pointer to your combo box.

therealjag
25th March 2006, 14:43
hey there i tried the currentIndex() function but it only works for the first item in the QComboBox and then gives the same output for the rest of the items as well. is there a way to distinguish between the itesm in the QCombobox so that they each give a different value for int selection, or call a seperate function each?

zlatko
27th March 2006, 08:21
Use next signal


void QComboBox::highlighted ( int index ) [signal]