PDA

View Full Version : Select multiple items in a combobox



sousadaniel7
23rd April 2012, 12:21
Hello

Can someone tell me how I can select multiple items in a combobox?


Regards,
Daniel Sousa

d_stranz
23rd April 2012, 17:42
Can someone tell me how I can select multiple items in a combobox?

You can't. That's whole idea of a combobox: You click the arrow, it opens, you select a new item, it closes, and the new item is displayed in the edit box. What kind of behaviour would you expect if you could select multiple items? Which one of them would you display in the edit box?

If you think you need to select multiple items from a list, then you should be using QListWidget.

sousadaniel7
23rd April 2012, 19:28
I wanted something this genre -> http://libqxt.bitbucket.org/doc/tip/qxtcheckcombobox.html

ChrisW67
23rd April 2012, 19:31
If you want the QxtCheckComboBox then use the Qxt library. Seems obvious enough.

Jonny174
24th April 2012, 04:50
Take this class QMultiComboBox

sousadaniel7
29th April 2012, 14:51
Take this class QMultiComboBox

Hello

Is not can you tell me how do I get items that are selected?

regards,
Daniel Sousa

d_stranz
29th April 2012, 16:46
If you want the QxtCheckComboBox then use the Qxt library. Seems obvious enough.

That seems like a reasonable solution to the UI problem I described earlier. Didn't realize I could stand up and see over the edge of the box.

sousadaniel7
29th April 2012, 17:57
That seems like a reasonable solution to the UI problem I described earlier. Didn't realize I could stand up and see over the edge of the box.

But is there any solution to my problem?

d_stranz
29th April 2012, 20:14
Is not can you tell me how do I get items that are selected?



QVariant QMultiComboBox::itemData(int row);


This code is from QMultiComboBox.h; it returns QVariant(true) if the item in "row" is checked, QVariant(false) if it isn't. You should be able to figure out how to use that method in your own code.

sousadaniel7
2nd May 2012, 14:35
Take this class QMultiComboBox

I implemented your class and it works well but appears in the layout looks like this:7666

How do I solve this?

And how can I increase the height of comboBox?

Spitfire
3rd May 2012, 12:15
Set correct minimum size, re-implement and return correct sizeHint() and set resonable size policies.
You may want to look at minimumSizeHint() as well.

sousadaniel7
3rd May 2012, 13:57
Set correct minimum size, re-implement and return correct sizeHint() and set resonable size policies.
You may want to look at minimumSizeHint() as well.

Have managed to solve this problem. But now and how I can increase the height of comboBox?