Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6923123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:29:42+00:00 2026-05-27T10:29:42+00:00

I am trying to make the items in a ComboBox checkable. I tried this:

  • 0

I am trying to make the items in a ComboBox checkable. I tried this:

http://programmingexamples.net/wiki/Qt/ModelView/ComboBoxOfCheckBoxes

where I subclassed QStandardItemModel and re-implemented the flags() function to make the items checkable. Then I added this model to the ComboBox. Unfortunately, a checkbox does not appear with the items. Can anyone see where I have gone wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:29:43+00:00Added an answer on May 27, 2026 at 10:29 am

    Have you set a check state as well as making them checkable?

    In my example below, this line is critical:

    item->setData(Qt::Unchecked, Qt::CheckStateRole);
    

    If it is omitted the check boxes won’t render as there isn’t a valid check-state to render.

    The example shows check boxes in a combobox, list and table, as I couldn’t get it to work at first either, so I tried different views.

    test.cpp

    #include <QtGui>
    
    int main(int argc, char** argv)
    {
        QApplication app(argc, argv);
    
        QStandardItemModel model(3, 1); // 3 rows, 1 col
        for (int r = 0; r < 3; ++r)
        {
            QStandardItem* item = new QStandardItem(QString("Item %0").arg(r));
    
            item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
            item->setData(Qt::Unchecked, Qt::CheckStateRole);
    
            model.setItem(r, 0, item);
        }
    
        QComboBox* combo = new QComboBox();
        combo->setModel(&model);
    
        QListView* list = new QListView();
        list->setModel(&model);
    
        QTableView* table = new QTableView();
        table->setModel(&model);
    
        QWidget container;
        QVBoxLayout* containerLayout = new QVBoxLayout();
        container.setLayout(containerLayout);
        containerLayout->addWidget(combo);
        containerLayout->addWidget(list);
        containerLayout->addWidget(table);
    
        container.show();
    
        return app.exec();
    }
    

    test.pro

    QT=core gui
    SOURCES=test.cpp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this wireframe I am working from: http://problemio.com/wireframe.pdf I am trying to make
I have this barebones code, I am trying to make it so some items
I'm trying to make an UI that contains a list of such items: http://img707.imageshack.us/img707/1114/16900293.png
Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:
I am trying to make a list with items. These items contain a checkbox
I'm trying to make a list of items (telephones and dependents for a customer),
I am trying to make a radio button list of 4 items. Each item
i am trying to make a colored dropdown list with colored items (please see
I'm trying to make a list of items that you can do several actions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.