From 7c661ce01f3d4e653ddc3c3195dbb5eeac3ab422 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Thu, 30 Apr 2020 22:17:14 +0200 Subject: [PATCH] Switch to QTableWidget for ingredients list --- ui_mainwindow.py | 18 ++++++++++++++++-- ui_mainwindow.ui | 27 +++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/ui_mainwindow.py b/ui_mainwindow.py index b0d2d6e..1db73a0 100644 --- a/ui_mainwindow.py +++ b/ui_mainwindow.py @@ -108,8 +108,18 @@ class Ui_MainWindow(object): self.t_ingredients.setObjectName("t_ingredients") self.horizontalLayout_14 = QtWidgets.QHBoxLayout(self.t_ingredients) self.horizontalLayout_14.setObjectName("horizontalLayout_14") - self.v_ingredients = QtWidgets.QListWidget(self.t_ingredients) + self.v_ingredients = QtWidgets.QTableWidget(self.t_ingredients) + self.v_ingredients.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) + self.v_ingredients.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.v_ingredients.setObjectName("v_ingredients") + self.v_ingredients.setColumnCount(2) + self.v_ingredients.setRowCount(0) + item = QtWidgets.QTableWidgetItem() + self.v_ingredients.setHorizontalHeaderItem(0, item) + item = QtWidgets.QTableWidgetItem() + self.v_ingredients.setHorizontalHeaderItem(1, item) + self.v_ingredients.horizontalHeader().setStretchLastSection(True) + self.v_ingredients.verticalHeader().setVisible(False) self.horizontalLayout_14.addWidget(self.v_ingredients) self.verticalLayout_7 = QtWidgets.QVBoxLayout() self.verticalLayout_7.setObjectName("verticalLayout_7") @@ -347,7 +357,7 @@ class Ui_MainWindow(object): self.menuBar.addAction(self.menuMen.menuAction()) self.retranslateUi(MainWindow) - self.tabWidget.setCurrentIndex(0) + self.tabWidget.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(MainWindow) MainWindow.setTabOrder(self.e_recipe_name, self.e_servings) MainWindow.setTabOrder(self.e_servings, self.e_time) @@ -385,6 +395,10 @@ class Ui_MainWindow(object): self.b_category_remove.setText(_translate("MainWindow", "Ausgewähltes entfernen")) self.b_category_add.setText(_translate("MainWindow", "Hinzufügen")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.t_basics), _translate("MainWindow", "Grundsätzliches")) + item = self.v_ingredients.horizontalHeaderItem(0) + item.setText(_translate("MainWindow", "Menge")) + item = self.v_ingredients.horizontalHeaderItem(1) + item.setText(_translate("MainWindow", "Zutat")) self.l_ingredient.setText(_translate("MainWindow", "Zutat")) self.l_amount.setText(_translate("MainWindow", "Menge")) self.c_heading.setText(_translate("MainWindow", "Zwischenüberschrift")) diff --git a/ui_mainwindow.ui b/ui_mainwindow.ui index 84390d7..396fb81 100644 --- a/ui_mainwindow.ui +++ b/ui_mainwindow.ui @@ -68,7 +68,7 @@ - 0 + 1 @@ -213,7 +213,30 @@ - + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + + Menge + + + + + Zutat + + +