Results 1 to 12 of 12

Thread: Select multiple items in a combobox

  1. #1
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Exclamation Select multiple items in a combobox

    Hello

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


    Regards,
    Daniel Sousa

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Select multiple items in a combobox

    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.

  3. #3
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Default Re: Select multiple items in a combobox


  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Select multiple items in a combobox

    If you want the QxtCheckComboBox then use the Qxt library. Seems obvious enough.

  5. The following user says thank you to ChrisW67 for this useful post:

    d_stranz (29th April 2012)

  6. #5
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Select multiple items in a combobox

    Take this class QMultiComboBox
    Attached Files Attached Files

  7. The following user says thank you to Jonny174 for this useful post:

    sousadaniel7 (29th April 2012)

  8. #6
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Default Re: Select multiple items in a combobox

    Quote Originally Posted by Jonny174 View Post
    Take this class QMultiComboBox
    Hello

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

    regards,
    Daniel Sousa

  9. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Select multiple items in a combobox

    Quote Originally Posted by ChrisW67 View Post
    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.

  10. #8
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Default Re: Select multiple items in a combobox

    Quote Originally Posted by d_stranz View Post
    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?

  11. #9
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Select multiple items in a combobox

    Is not can you tell me how do I get items that are selected?
    Qt Code:
    1. QVariant QMultiComboBox::itemData(int row);
    To copy to clipboard, switch view to plain text mode 

    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.

  12. The following user says thank you to d_stranz for this useful post:

    sousadaniel7 (2nd May 2012)

  13. #10
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Default Re: Select multiple items in a combobox

    Quote Originally Posted by Jonny174 View Post
    Take this class QMultiComboBox
    I implemented your class and it works well but appears in the layout looks like this:comboBox.png

    How do I solve this?

    And how can I increase the height of comboBox?
    Last edited by sousadaniel7; 2nd May 2012 at 15:16.

  14. #11
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Select multiple items in a combobox

    Set correct minimum size, re-implement and return correct sizeHint() and set resonable size policies.
    You may want to look at minimumSizeHint() as well.

  15. #12
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Default Re: Select multiple items in a combobox

    Quote Originally Posted by Spitfire View Post
    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?

Similar Threads

  1. set combobox delegate on some view items
    By GrahamLabdon in forum Newbie
    Replies: 0
    Last Post: 8th March 2011, 14:36
  2. How to get a Multi select combobox
    By calmspeaker in forum Qt Programming
    Replies: 9
    Last Post: 26th August 2008, 05:49
  3. Combobox with checkable items
    By qtneuling in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2008, 14:42
  4. Sorting Combobox Items
    By raphaelf in forum Newbie
    Replies: 5
    Last Post: 23rd June 2008, 08:00
  5. Creating events for combobox items
    By confused in forum Newbie
    Replies: 4
    Last Post: 26th March 2006, 16:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.