Custom QCheckbox in QT widgets
-
So;
I am trying to create a QTableWidget that will have checkboxes in some columns and I have two scenarios. The first I want to have one column with text and a checkbox. The Second scenario, I want to have two columns each with checkboxes.I hav this implemented and it works great. However, Now I need to make the checkboxes have custom states that are driven by graphic.svg files for each state. I was hoping to do this with a stylesheet but have had huge trouble. Most examples are kindof QtQuick related and I do not see anything that is in the QtWidgets world.
Does anyone have any code or example of this?
I really appreciate any help.
Thanks! -
@EagleSparrow said in Custom QCheckbox in QT widgets:
I hav this implemented and it works great.
You might want to state, briefly, how you have gone about adding these checkboxes into your
QTableWidget
? -
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.