QCheckbox overlap with Table item value
-
wrote on 4 Jun 2020, 04:18 last edited by
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 -
wrote on 4 Jun 2020, 09:21 last edited by VRonin 6 Apr 2020, 09:25
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 -
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
2/3