lundi 13 avril 2020

QComboBox checkbox: Removing the square

I have a drop down QComboBox that includes a checkbox with a tick mark if it is the selected item. Is there a way to just see the tick mark without the square?

    // Add checkboxes
    QSortFilterProxyModel *pProxy;
    QStandardItemModel    *pSource;
    for (int idx = 0; idx < m_pComboBox->count(); idx++)
    {
        // Add check mark for current 
        pProxy = (QSortFilterProxyModel*) m_pComboBox->model();
        auto const proxyIndex = pProxy->index(idx, 0);

        pSource = (QStandardItemModel*) pProxy->sourceModel();
        auto const sourceIndex = pProxy->mapToSource(proxyIndex);

        if (idx == m_currSelectedIndex)
        {
            pSource->setData(sourceIndex, Qt::Checked, Qt::CheckStateRole);
        }
        else
        {
            pSource->setData(sourceIndex, Qt::Unchecked, Qt::CheckStateRole);
        }
    }

So basically I just want to see either a tick mark or a blank. Is there a way not to show the checkbox square or make it transparent?




Aucun commentaire:

Enregistrer un commentaire