Dec-15-2018, 10:43 AM
(This post was last modified: Dec-15-2018, 11:40 AM by Axel_Erfurt.)
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:
#!/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_())