Home > other >  How to make the cell's control center in the QTableWidget
How to make the cell's control center in the QTableWidget

Time:01-11

How to make the cell's control center in the QTableWidget

CodePudding user response:



 QCheckBox * checkBox []={new QCheckBox, new QCheckBox, new QCheckBox}; 

Int column [] {9, 11, 13};
for (int i=0; i <3; I++) {
QWidget * widget=new QWidget;
QHBoxLayout * hLayout=new QHBoxLayout ();
HLayout - & gt; AddWidget (checkBox [I]);
HLayout - & gt; SetMargin (0);
//set the horizontal center
HLayout - & gt; SetAlignment (widgets, Qt: : AlignCenter);
//set parts around the left, and right, bottom margin
HLayout - & gt; SetContentsMargins (10, 0, 10, 0).
//add layout
Widgets - & gt; SetLayout (hLayout);
//add cell
UI. TableWidget - & gt; SetCellWidget (row, column [I], widget);

}
  • Related