View Full Version : Creating events for combobox items
confused
25th March 2006, 22:49
hey every1 this is my first post so im not sure if any1 will reply but here it goes. i have created a QCombobox and i have added 3 items to it. for each item i want it to signal a seperate event. is it possible to do this or should i use some other widget. i tried using highlighted() and activated() but they only seem to work for the combobox as a whole, is there anything i could use?
jacek
25th March 2006, 23:04
Both of these signals carry the item index:
void QComboBox::activated ( int index ) [signal]
This signal is sent when an item in the combobox is activated by the user. The item's index is given.
confused
25th March 2006, 23:28
I tried the function with the following piece of code:
connect(comboBox1, SIGNAL(activated(int 1)), this, SLOT(item1Chosen()));
but the debug says there is no such signal? do i have to set up the item's index manually?how would i go about doing that?
jacek
26th March 2006, 00:33
but the debug says there is no such signal?
Because you can't put parameter values in SIGNAL or SLOT macros.
Try this:
connect( comboBox1, SIGNAL( activated( int ) ),
this, SLOT( itemChosen( int ) ) );
confused
26th March 2006, 16:40
ok yeah i understand what ur trying to say now - i figured it out. thanks for the help
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.