alignment for QCheckBox in QTableWidget
-
wrote on 10 Jan 2020, 22:39 last edited by cow_goes_meow 1 Oct 2020, 22:40
-
Hi and welcome to devnet,
How did you create them ?
-
wrote on 13 Jan 2020, 15:41 last edited by
I think something reproducible would be:
ccHeaders = QtWidgets.QTableWidget()
checkbox = QtWidgets.QCheckBox()
ccHeaders.setCellWidget(0, 0, checkbox) -
wrote on 13 Jan 2020, 17:54 last edited by
@Denni-0 said in alignment for QCheckBox in QTableWidget:
The alignment is not part of checkbox that is why you cannot find it -- the alignment feature is actually part of tablewidget and more precisely that column of your tablewidget
I looked for alignment in qtablewidget also, and couldn't find anything: https://doc.qt.io/qtforpython/PySide2/QtWidgets/QTableWidget.html
I know set alignment is in a tablewidgetitem, but this isn't considered an item, right?
-
Why not use the Qt.ItemIsUserCheckable flag to get the checkboxes you want rather than widgets San you are doing ?
Widgets set like that will not respond to any role because they are not part of the rendering of the model.
-
Nop, using
setIndexWidgetsetCellWidget puts a widget on that cell but it does not care about the model content.The documentation clearly indicates that it should only be used on special cases for static content and not like done currently to show widgets on each and every line.
-
You didn't (and it was setCellWidget, my bad) but the OP did.
It comes from the original post -
Why not use the Qt.ItemIsUserCheckable flag to get the checkboxes you want rather than widgets San you are doing ?
Widgets set like that will not respond to any role because they are not part of the rendering of the model.
wrote on 21 Jan 2020, 22:02 last edited by@SGaist said in alignment for QCheckBox in QTableWidget:
Why not use the Qt.ItemIsUserCheckable flag to get the checkboxes you want rather than widgets San you are doing ?
Widgets set like that will not respond to any role because they are not part of the rendering of the model.
I originally went with this and had issues with how I coded it, so I went with the checkbox route. But a clear head does wonders, and I did it this way. Thank you guys.
-
wrote on 26 Nov 2020, 02:12 last edited by
I know this topic is marked solved, but I can't figure out what anyone is saying the solution is. So to be helpful I suggest using setSyleSheet().
For example:
QCheckBox * cb = new QCheckBox("Show");
cb->setStyleSheet("padding-left: 10px;");
tileInfoTable->setCellWidget(TI_SHOW,col,cb);