diff --git a/report.py b/report.py index cfe3b5f..997fa00 100644 --- a/report.py +++ b/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() diff --git a/task_edit.py b/task_edit.py index 1113a46..cda6d2e 100644 --- a/task_edit.py +++ b/task_edit.py @@ -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()