QCheckbox overlap with Table item value
Solved
General and Desktop
-
I am adding QCheckbox as QStandardItem in QTableView via a delegate class.
But the value is also getting added and are overlapped.
As in the image, the value is false, so a unchecked checkbox only should appear. But the value is also getting added below the checkboxAnd when we make it checked, true is coming at behind.
Any suggestion, why the value is also appearing behind the checkbox.
Regards,
Sayan -
Adding checkboxes does not require custom delegates.
all you need to do is:standardItem->setData(Qt::Unchecked,Qt::CheckStateRole); // makes the checkbox appear standardItem->setFlags(standardItem->flags() | Qt::ItemIsUserCheckable); // the user can click on the checkbox to toggle it
P.S.
Foreseeing your next question: https://forum.qt.io/topic/94049/how-to-center-a-column-with-a-checkbox-in-qtableview