Improve table column sizes
This commit is contained in:
parent
c3cde56eb8
commit
30c4035eff
12
report.py
12
report.py
@ -2,6 +2,8 @@ from PySide2 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from PySide2.QtWidgets import QHeaderView
|
||||
|
||||
from data import Tasks
|
||||
|
||||
|
||||
@ -37,7 +39,10 @@ class Report(QtWidgets.QDialog):
|
||||
self.tableWidget.cellChanged.connect(self.cell_changed)
|
||||
self.tableWidget.setItemDelegateForColumn(0, Report.TaskItemCompleter(self._tasks, self))
|
||||
self.header = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal)
|
||||
self.header.setMinimumSectionSize(1)
|
||||
self.header.setSectionResizeMode(QHeaderView.ResizeToContents)
|
||||
self.tableWidget.setHorizontalHeader(self.header)
|
||||
self.header.setSectionResizeMode(self.header.logicalIndex(0), QHeaderView.Stretch)
|
||||
|
||||
self.previous_button = QtWidgets.QPushButton()
|
||||
self.previous_button.setText("Previous")
|
||||
@ -112,13 +117,8 @@ class Report(QtWidgets.QDialog):
|
||||
item1.setFlags(item0.flags() & QtCore.Qt.ItemIsEnabled)
|
||||
self._changing_items = False
|
||||
|
||||
self.tableWidget.resizeColumnsToContents()
|
||||
self.tableWidget.resizeColumnToContents(0)
|
||||
|
||||
min_width = 0
|
||||
for i in range(3):
|
||||
min_width += self.header.sectionSize(i)
|
||||
self.tableWidget.setMinimumWidth(min_width * 1.33)
|
||||
self.header.setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
|
||||
if self.tableWidget.rowCount() > 4:
|
||||
if hasattr(self.tableWidget, "screen"):
|
||||
screen_height = self.tableWidget.screen().size().height()
|
||||
|
@ -9,6 +9,7 @@ class TaskEdit(QtWidgets.QDialog):
|
||||
|
||||
self.tableView = QtWidgets.QTableView()
|
||||
self.tableView.setModel(self.list)
|
||||
self.tableView.horizontalHeader().setStretchLastSection(True)
|
||||
self.tableView.horizontalHeader().hide()
|
||||
self.tableView.verticalHeader().hide()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user