Erik1984
November 18th, 2012, 03:11 PM
Ok there I am again with another Python question :P I have a few problems with a TableView widget in my PyQt program. I succeed in setting a table model and display that but the layout is not as I would expect (as can be seen in the attached image).
Basically there are three problems:
1. Checkboxes on each cell, how to get rid of them?
2. The text in the columns is not vertically aligned, could that be because one contains a number and the other a string?
3. The columns don't fill the whole table width.
Any ideas how to get that right?
Here is the code responsible for drawing the inteface:
def initUI(self):
self.setGeometry(300, 300, 350, 300)
self.setWindowTitle('Table Test')
button = QtGui.QPushButton('Test Button', self)
button.clicked.connect(self.buttonClicked)
self.dateEdit = QtGui.QDateTimeEdit(QtCore.QDate.currentDate())
self.dateEdit.setMinimumDate(QtCore.QDate.currentD ate().addDays(-365))
self.dateEdit.setMaximumDate(QtCore.QDate.currentD ate().addDays(365))
self.dateEdit.setDisplayFormat("yyyy.MM.dd");
self.groupbox = QtGui.QGroupBox("Entry")
self.groupboxLayout = QtGui.QVBoxLayout(self)
self.groupboxLayout.addWidget(self.dateEdit)
self.groupboxLayout.addWidget(button)
self.groupbox.setLayout(self.groupboxLayout)
self.tableModel = MyTableModel(self.database)
self.tableView = QtGui.QTableView()
self.tableView.setModel(self.tableModel)
layout = QtGui.QVBoxLayout(self)
layout.addWidget(self.tableView)
layout.addWidget(self.groupbox)
self.setLayout(layout)
self.show()
If you need more pieces of the code I can of course provide them but pasting the entire source might be distracting.
Basically there are three problems:
1. Checkboxes on each cell, how to get rid of them?
2. The text in the columns is not vertically aligned, could that be because one contains a number and the other a string?
3. The columns don't fill the whole table width.
Any ideas how to get that right?
Here is the code responsible for drawing the inteface:
def initUI(self):
self.setGeometry(300, 300, 350, 300)
self.setWindowTitle('Table Test')
button = QtGui.QPushButton('Test Button', self)
button.clicked.connect(self.buttonClicked)
self.dateEdit = QtGui.QDateTimeEdit(QtCore.QDate.currentDate())
self.dateEdit.setMinimumDate(QtCore.QDate.currentD ate().addDays(-365))
self.dateEdit.setMaximumDate(QtCore.QDate.currentD ate().addDays(365))
self.dateEdit.setDisplayFormat("yyyy.MM.dd");
self.groupbox = QtGui.QGroupBox("Entry")
self.groupboxLayout = QtGui.QVBoxLayout(self)
self.groupboxLayout.addWidget(self.dateEdit)
self.groupboxLayout.addWidget(button)
self.groupbox.setLayout(self.groupboxLayout)
self.tableModel = MyTableModel(self.database)
self.tableView = QtGui.QTableView()
self.tableView.setModel(self.tableModel)
layout = QtGui.QVBoxLayout(self)
layout.addWidget(self.tableView)
layout.addWidget(self.groupbox)
self.setLayout(layout)
self.show()
If you need more pieces of the code I can of course provide them but pasting the entire source might be distracting.