Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QComboBox - how to click on QStandardItem?
Forum Updated to NodeBB v4.3 + New Features

QComboBox - how to click on QStandardItem?

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 697 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TomNow99
    wrote on last edited by TomNow99
    #1

    Hello,

    I try to create QComboBox with checkBoxes. Now I have QComboBox, and add to it QStandardItems.

    my code:

    void myComboBox::addItem(const QString &text)
    {
        int row = model->rowCount();
        QStandardItem* item = new QStandardItem();
        item->setText(text);
        item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
        item->setData(Qt::Unchecked, Qt::CheckStateRole);
        model->setItem(row, 0, item);
        this->setModel(model);
    }
    

    tmp3.png

    When I click on red area everything is ok - I can checked and unchecked the item. But when I click on green area there is no effect.

    Goal: When I click on item in green area I would like to checked or unchecked his red area square and don't close comboBox ( because this is combobox with checkBoxes, so user maybe want to select more items ).

    I try QComboBox' s signals but there is no effect.

    EDIT:
    I add:

    item->setSelectable(true);
    

    and signal

    QComboBox::activated
    

    Now I can click on green area and change his checked/unchecked square ( red area ). But the problem is when I clicked on any item I close QComboBox too…

    EDIT 2:
    I add to slot to signal QComboBox::activated

    myComboBox::showPopup();
    

    This is good, but I see that qcombobox is close and next is open. So must be better solution

    EDIT 3:
    I find solution:

    https://stackoverflow.com/questions/22813494/qcombobox-with-checkboxes

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved