Skip to content
  • 0 Votes
    6 Posts
    693 Views
    S

    @ChrisW67 It did not. I ended up reinstalling Linux and that seems to have fixed it. I still have the old install available so I'd like to find out the root cause still.

  • 0 Votes
    3 Posts
    715 Views
    A

    @Christian-Ehrlicher Oh, so stupid of mine for not thinking about it ahha
    thanks!

    RESULT for future noobie like me:

    for(int row=0;row<=12;row++){ QHBoxLayout *a = new QHBoxLayout(); a->addWidget((new QCheckBox(""))); QWidget *z = new QWidget(); z->setLayout(a); ui->tableWidget->setCellWidget(row,0, z); }
  • 0 Votes
    4 Posts
    545 Views
    SGaistS

    If this is reproducible with C++, then C++ since the Python bindings are built on top of it.

  • 0 Votes
    3 Posts
    845 Views
    EagleSparrowE

    Here is the code.

    QList<SomeClass> ModeTableEntries ; for (int row = 0; row < ModeTableEntries .length(); row++) { ui->EntriesTableWidget->insertRow(row); ui->EntriesTableWidget->setRowHeight(row, 45); ModeValues value = ModeTableEntries [row]; QTableWidgetItem* currentItem = new QTableWidgetItem(value .ModeText); if(TestModeEnabled == true) currentItem->setCheckState(Qt::Checked); else currentItem->setCheckState(Qt::Unchecked); ui->EntriesTableWidget->setItem( row, 0, currentItem); currentItem->setFlags(currentItem->flags()^(Qt::ItemIsEditable )); }

    The problem is that I cannot style the default implementation of the QTableWidgetItem(QCheckbox) that is part of the QTableWidgetItem.

  • 0 Votes
    3 Posts
    550 Views
    S

    @VRonin Thanks.
    It worked.
    We have used delegates because we have combobox, lineedit also.
    So we have put check for combobox, not to update via delegate.

  • 0 Votes
    3 Posts
    1k Views
    ptstreamP

    I think I have found a solution that is not necessarily complete (e.g. drive the combbox with keyboard).

    I add a boolean (e.g. mSkipToogle=false) at the same place than mSkipHide.

    I rewrite eventFilter (QObject* object, QEvent* event).

    bool CFilterCountryComboBox::eventFilter (QObject* object, QEvent* event) { QEvent::Type type = event->type (); if (object == view ()->viewport ()) { switch (type) { case QEvent::MouseButtonRelease : case QEvent::MouseButtonPress : mSkipHide = true; mSkipToogle = false; break; case QEvent::Hide : case QEvent::Show : mSkipToogle = true; break; default : break; } } if (type == QEvent::MouseButtonRelease && static_cast<QMouseEvent*>(event)->button () == Qt::RightButton) { return true; } return QComboBox::eventFilter (object, event); } Now rewrite toggleItemCheckState (int index) void CFilterCountryComboBox::toggleItemCheckState (int index) { if (!mSkipToogle) { QVariant value = itemData (index, Qt::CheckStateRole); Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt ()); setItemData (index, (state == Qt::Unchecked ? Qt::Checked : Qt::Unchecked), Qt::CheckStateRole); } else { mSkipToogle = false; } }

    It seems to work on Windows with Qt 5.12.7.
    Good luck

  • 0 Votes
    4 Posts
    3k Views
    JonBJ

    @pauledd
    You mean the background color "overspill" to right & bottom? I don't know but you might play with border-... or padding-... (I'm thinking margin- does not use background color, but I might be wrong) having a width/transparency/grey....

  • Problem with the QCheckBox

    Unsolved General and Desktop
    4
    0 Votes
    4 Posts
    977 Views
    SGaistS

    What does condition contain ?

  • 0 Votes
    5 Posts
    3k Views
    Y

    Thank you @mrjj and @Christian for answer. I am able to make user Checkable.

    class CustomListModel : public QStandardItemModel {
    public:
    Qt::ItemFlags CustomListModel::flags(const QModelIndex & index) const {
    Qt::ItemFlags defaultFlags = QStandardItemModel::flags(index);
    if (index.isValid()) {
    return defaultFlags | Qt::ItemIsUserCheckable;
    }
    return defaultFlags;
    }

    CustomListModel(const int row, const int coloumn) : QStandardItemModel(row, coloumn) { }

    };

    and modification.
    hwListProxyModel->setSourceModel(new CustomListModel (0, 0));

  • 0 Votes
    12 Posts
    3k Views
    Pradeep KumarP

    @Sumit

    Glad u got the result,
    Happy Coding,

    Thanks,

  • 0 Votes
    4 Posts
    6k Views
    CybeXC

    Here is a possible solution for solving this "missing check/mark" issue.

    I implemented the CSS "indicator" solution I got from this qt form post which is problematic.

    Sources of solution:

    Doc page: here Implementation: here QPalette p = ui->checkBox->palette(); p.setColor(QPalette::Active, QPalette::Base, QColor(255, 255, 255)); p.setColor(QPalette::Button, QColor(255, 255, 255)); ui->checkBox->setAutoFillBackground(true); ui->checkBox->setPalette(p); QColor(255, 255, 255)

    refers to your desired background color, possibly the same color as your window background, etc.

    QPallete::Active, QPalette::base

    refers to the active checkbox's background (the white box background)

    QPalette::Button

    refers to the "actual background" (behind the checkbox and the checkbox text)

    Hope this helps!

  • 0 Votes
    5 Posts
    3k Views
    _

    @_compiler said:

    thanks.

  • 0 Votes
    6 Posts
    4k Views
    D

    QCheckBox inherits from QAbstractButton, which provides a hitButton method that controls which parts of the button are clickable. All you need to do is make a new subclass of QCheckBox and override hitButton so it always returns true:

    class BigHitCheckBox : public QCheckBox { bool hitButton(const QPoint & pos) const override { Q_UNUSED(pos); return true; } };

    This is much simpler than the solutions previously mentioned, and it should play well with the hovering, disabling, and tristate features of the checkbox without any extra effort.

    By the way, this makes the entire checkbox widget clickable, but it doesn't make other widgets outside the checkbox clickable. I don't think the OP needed that.

    --David

  • 0 Votes
    3 Posts
    2k Views
    J

    Nevermind - in the end it turned out the label was modeled as a separate QLabel instead of the text of the QCheckBox. Once I removed the label, and put the text inside the checkbox, I got exactly what I was asking for.

  • 0 Votes
    3 Posts
    1k Views
    N

    I am not really sure what you want to do, but maybe a QButtonGroup could be helpful?