I'm trying to do this with the check-box.
Sadly is made for C++ and any adaptation of the code for Python has the result this error: 'QWidget' object is not callable
What I wanna to do is to add a check-box on each row, this is my code:
pWidget = QWidget()
pCheckbox = QCheckBox()
pLayout = QVBoxLayout()
pLayout.addWidget(pCheckbox)
pLayout.setAlignment(Qt.AlignCenter)
pLayout.setContentsMargins(0, 0 ,0, 0)
pWidget.setLayout(pLayout)
for char in accounts:
for columnNumber in range(numberColumns):
chkBoxItem = QTableWidgetItem()
chkBoxItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
chkBoxItem.setCheckState(Qt.Unchecked)
self.mainAccountTable.insertRow(currentRowCount)
self.mainAccountTable.setItem(currentRowCount, 0, pWidget(chkBoxItem))
self.mainAccountTable.setItem(currentRowCount, 1, QTableWidgetItem(data[1]))
If I put pLayout = Layout()
is saying that it isn't implemented in Python.
So, how I can I add that checkbox aligned in center without the text area near for each row? Thanks in advance for any tips.
Later EDIT: moving the code inside the loop is working , but I can't control the checks:
for char in accounts:
for columnNumber in range(numberColumns):
pWidget = QWidget()
pCheckbox = QCheckBox()
pLayout = QVBoxLayout(pWidget)
pLayout.addWidget(pCheckbox)
pLayout.setAlignment(Qt.AlignCenter)
pLayout.setContentsMargins(0, 0 ,0, 0)
pWidget.setLayout(pLayout)
#chkBoxItem = QTableWidgetItem()
#chkBoxItem.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
#chkBoxItem.setCheckState(Qt.Unchecked)
self.mainAccountTable.insertRow(currentRowCount)
self.mainAccountTable.setCellWidget(currentRowCount, 0, pWidget)
This is a screenshoot How can I know what I checked and build set list?