how to insert QCheckbox into center of items in a QTableView?
-
Hi,I have a tableview and insert a QCheckbox into the item of the second column. I use model-view-control frame to display the data.
in data() of the model file:
if (role == Qt::TextAlignmentRole)
{
switch (column) {
case 0: {
return int(Qt::AlignLeft|Qt::AlignVCenter);
break;
}
case 1:
{
return int(Qt::AlignCenter);
break;
}
}
}I use the following code to set the alignment of the checkbox to be in the center of the item but with no use?
what should I do to set the alignment? -
Hi,I have a tableview and insert a QCheckbox into the item of the second column. I use model-view-control frame to display the data.
in data() of the model file:
if (role == Qt::TextAlignmentRole)
{
switch (column) {
case 0: {
return int(Qt::AlignLeft|Qt::AlignVCenter);
break;
}
case 1:
{
return int(Qt::AlignCenter);
break;
}
}
}I use the following code to set the alignment of the checkbox to be in the center of the item but with no use?
what should I do to set the alignment?@yangyanhui4 said in how to insert QCheckbox into center of items in a QTableView?:
what should I do to set the alignment?
You need a custom QStyledItemDelegate.