Python Forum
PyQt, Open a Table when a row is selected populating it with the row values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt, Open a Table when a row is selected populating it with the row values
#4
Quote:self.comboBox.setMaximumSize(16777215, 50)

16777215 ???

If you want a fixed width for the first combobox use

self.comboBox.setFixedWidth(100)


Quote:self.tableWidget.setGeometry(QtCore.QRect(320, 260, 771, 271))
(and all the other geometry)

why QtCore.QRect( ?

just use

self.tableWidget.setGeometry(10, 260, 771, 271)

Normally it is better to make a layout instead of always using "setGeometry".

I have no Qt4, did a test in Qt5 with your code.
I have renamed everything so you know what you are working on.
And I have positioned everything differently.
This is how it looks like:

[Image: dialogtest.png]

#!/usr/bin/python3
# -*- coding: utf-8 -*-
from PyQt5 import QtCore, QtWidgets
 
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.setEnabled(True)
        Dialog.setGeometry(0, 0, 830, 700)
        Dialog.setMinimumSize(830, 400)

        self.product_id_box = QtWidgets.QComboBox(Dialog)
        self.product_id_box.setGeometry(10, 70, 100, 32)
        self.product_id_box.setFixedWidth(100)
        self.product_id_box.setEditable(True)
        self.product_id_box.setObjectName("comboBox")

        self.product_name_box = QtWidgets.QComboBox(Dialog)
        self.product_name_box.setGeometry(120, 70, 291, 32)
        self.product_name_box.setEditable(True)
        self.product_name_box.setObjectName("comboBox_3")

        self.product_id_lbl = QtWidgets.QLabel(Dialog)
        self.product_id_lbl.setGeometry(20, 50, 71, 20)
        self.product_id_lbl.setObjectName("label")
        self.product_id_lbl.setText("product_id")

        self.product_name_lbl = QtWidgets.QLabel(Dialog)
        self.product_name_lbl.setGeometry(240, 50, 101, 20)
        self.product_name_lbl.setObjectName("label_2")
        self.product_name_lbl.setText("Product_name")

        self.product_price_lbl = QtWidgets.QLabel(Dialog)
        self.product_price_lbl.setGeometry(460, 50, 60, 16)
        self.product_price_lbl.setObjectName("label_3")
        self.product_price_lbl.setText("price")

        self.product_quantity_lbl = QtWidgets.QLabel(Dialog)
        self.product_quantity_lbl.setGeometry(564, 50, 60, 16)
        self.product_quantity_lbl.setObjectName("label_4")
        self.product_quantity_lbl.setText("quantity")
   
        self.product_value_lbl = QtWidgets.QLabel(Dialog)
        self.product_value_lbl.setGeometry(710, 50, 60, 16)
        self.product_value_lbl.setObjectName("label_5")
        self.product_value_lbl.setText("value")

        self.lineEdit_price = QtWidgets.QLineEdit(Dialog)
        self.lineEdit_price.setGeometry(420, 70, 113, 32)
        self.lineEdit_price.setObjectName("lineEdit_price")
        self.lineEdit_price.setPlaceholderText("price")

        self.lineEdit_quantity = QtWidgets.QLineEdit(Dialog)
        self.lineEdit_quantity.setGeometry(540, 70, 113, 32)
        self.lineEdit_quantity.setObjectName("lineEdit_quantity")
        self.lineEdit_quantity.setPlaceholderText("quantity")

        self.product_value_box = QtWidgets.QComboBox(Dialog)
        self.product_value_box.setGeometry(660, 70, 160, 32)
        self.product_value_box.setEditable(True)
        self.product_value_box.setObjectName("comboBox_4")

        self.line = QtWidgets.QFrame(Dialog)
        self.line.setGeometry(10, 4, 810, 16)
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")

        self.line_2 = QtWidgets.QFrame(Dialog)
        self.line_2.setGeometry(10, 42, 810, 16)
        self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_2.setObjectName("line_2")

        self.line_3 = QtWidgets.QFrame(Dialog)
        self.line_3.setGeometry(10, 100, 810, 16)
        self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_3.setObjectName("line_3")

        self.tableWidget = QtWidgets.QTableWidget(Dialog)
        self.tableWidget.setGeometry(10, 104, 810, 271)
        self.tableWidget.setRowCount(1)
        self.tableWidget.setColumnCount(5)
        self.tableWidget.setObjectName("tableWidget")

        self.editButton_3 = QtWidgets.QPushButton(Dialog)
        self.editButton_3.setGeometry(10, 14, 110, 32)
        self.editButton_3.setObjectName("pushButton_3")
        self.editButton_3.setText("Edit")

        self.deleteButton_4 = QtWidgets.QPushButton(Dialog)
        self.deleteButton_4.setGeometry(126, 14, 110, 32)
        self.deleteButton_4.setObjectName("pushButton_4")
        self.deleteButton_4.setText("Delete")

        self.clearButton = QtWidgets.QPushButton(Dialog)
        self.clearButton.setGeometry(586, 14, 113, 32)
        self.clearButton.setText("Clear")
        self.clearButton.setObjectName("pushButton")

        self.saveButton = QtWidgets.QPushButton(Dialog)
        self.saveButton.setGeometry(706, 14, 113, 32)
        self.saveButton.setObjectName("pushButton_2")
        self.saveButton.setText("Save")

        QtCore.QMetaObject.connectSlotsByName(Dialog)

        Dialog.setWindowTitle("Products")
        Dialog.statusBar().showMessage("Ready")
        
 
if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QMainWindow()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())
Reply


Messages In This Thread
RE: PyQt, Open a Table when a row is selected populating it with the row values - by Axel_Erfurt - Dec-15-2018, 10:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] populating dropdown from Method mikisDW 2 3,915 Apr-06-2020, 08:06 PM
Last Post: mikisDW
  Populating a Listbox from db Query DT2000 2 6,539 Feb-25-2019, 05:45 PM
Last Post: DT2000
  PyQt Selected row in Table Widget rarevesselt 3 23,862 Dec-07-2018, 07:00 PM
Last Post: rarevesselt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020