In my Qt C++ Windows application, I create checkboxes in my table using roles:
QTableWidgetItem* item = new QTableWidgetItem();
item->setData(Qt::CheckStateRole, QVariant::fromValue(dev.is_active ? Qt::Checked : Qt::Unchecked));
ui.tableWidget->setItem(i, ui_columns_positions.at(table_columns::IsActive), item);
The problem is that checkboxes are left-aligned. I need to align them to the center of the cell.
I've already tried various alignment methods, but none of them work. For example, I created a style for alignment, I made a delegate class - nothing worked. How to align checkboxes created using roles to the center of the cell in QTableWidget?
Aucun commentaire:
Enregistrer un commentaire