Answer the question
In order to leave comments, you need to log in
How to implement settings for the table?
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QTableWidgetItem, QMainWindow, QApplication, QTableWidget
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.tablewidget = QTableWidget(4, 1)
self.setCentralWidget(self.tablewidget)
for row in range(4):
item = QTableWidgetItem("index_" + str(row))
item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
item.setCheckState(Qt.Unchecked)
self.tablewidget.setItem(row, 0, item)
self.tablewidget.cellChanged.connect(self.onCellChanged)
def onCellChanged(self, row, column):
item = self.tablewidget.item(row, column)
print(item.text())
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Separate display and data. Store checkboxes in a separate object, update the state of these flags when the UI changes.
And reading/writing ini files via https://docs.python.org/3/library/configparser.html can be done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question