Results 1 to 2 of 2

Thread: Would like to know how to add a Checkbox as an item to a combo Box

  1. #1
    Join Date
    Mar 2011
    Posts
    1
    Qt products
    Platforms
    Windows

    Default Would like to know how to add a Checkbox as an item to a combo Box

    Hi All,

    I'm using PyQT as my toolkit for my GUI Development and I have a requirement to add checkboxes as items of a combo box. I would like to know how to achieve this. I tried searching but no luck so far. so just thought of seeking your help.

    Folloiwng is the code that I have written.

    class CheckboxInsideListbox(QWidget):
    def __init__(self, parent = None):
    super(CheckboxInsideListbox, self).__init__(parent)
    self.setGeometry(250,250,300,300)
    self.MainUI()

    def MainUI(self):
    #stb_label = QLabel("Select STB\'s")
    stb_combobox = QComboBox()
    length = 10
    cb_layout = QVBoxLayout(stb_combobox)
    for i in range(length):
    c = QCheckBox("STB %i" % i)
    cb_layout.addWidget(c)

    main_layout = QVBoxLayout()
    main_layout.addWidget(stb_combobox)
    main_layout.addLayout(cb_layout)
    self.setLayout(main_layout)

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Would like to know how to add a Checkbox as an item to a combo Box

    Set a model on the combobox that will handle CheckStateRole. Then disable the popup flag from combobox's popup.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Adding an item to combo box dynamiacally
    By madhukiranmp in forum Newbie
    Replies: 3
    Last Post: 3rd January 2011, 07:36
  2. Stylesheet of selected item in combo-box
    By shrawan0786 in forum Qt Programming
    Replies: 1
    Last Post: 6th December 2010, 11:30
  3. Replies: 1
    Last Post: 29th June 2010, 18:59
  4. DropDown combo box
    By Tavit in forum Qt Programming
    Replies: 3
    Last Post: 3rd May 2008, 09:40
  5. QTableWidget item checkable and combo?
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2006, 08:12

Tags for this Thread

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.