Chào cả nhà.
Em đang học PyQt4, dùng Qtdesigner thiết kế 1 giao diện đơn giản như hình.
Em thắc mắc là set layout thế nào để khi buil ra có thể cầm chuột kéo giãn mà nội dung trong đó kéo giản theo ạ?
Và đây là code ạ.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'doreamon.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(710, 405)
self.lable_head = QtGui.QLabel(Form)
self.lable_head.setGeometry(QtCore.QRect(0, 0, 711, 51))
self.lable_head.setText(_fromUtf8(""))
self.lable_head.setPixmap(QtGui.QPixmap(_fromUtf8("doreamon.jpg")))
self.lable_head.setScaledContents(True)
self.lable_head.setObjectName(_fromUtf8("lable_head"))
self.tableWidget = QtGui.QTableWidget(Form)
self.tableWidget.setGeometry(QtCore.QRect(0, 100, 191, 261))
self.tableWidget.setObjectName(_fromUtf8("tableWidget"))
self.tableWidget.setColumnCount(2)
self.tableWidget.setRowCount(0)
item = QtGui.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(0, item)
item = QtGui.QTableWidgetItem()
self.tableWidget.setHorizontalHeaderItem(1, item)
self.label_1 = QtGui.QLabel(Form)
self.label_1.setGeometry(QtCore.QRect(70, 70, 91, 20))
self.label_1.setObjectName(_fromUtf8("label_1"))
self.label_2 = QtGui.QLabel(Form)
self.label_2.setGeometry(QtCore.QRect(470, 70, 53, 16))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.graphicsView = QtGui.QGraphicsView(Form)
self.graphicsView.setGeometry(QtCore.QRect(210, 100, 491, 261))
self.graphicsView.setObjectName(_fromUtf8("graphicsView"))
self.lineEdit = QtGui.QLineEdit(Form)
self.lineEdit.setGeometry(QtCore.QRect(0, 370, 521, 31))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.pushButton_ok = QtGui.QPushButton(Form)
self.pushButton_ok.setGeometry(QtCore.QRect(530, 370, 71, 28))
self.pushButton_ok.setObjectName(_fromUtf8("pushButton_ok"))
self.pushButton_exit = QtGui.QPushButton(Form)
self.pushButton_exit.setGeometry(QtCore.QRect(620, 370, 61, 28))
self.pushButton_exit.setObjectName(_fromUtf8("pushButton_exit"))
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
item = self.tableWidget.horizontalHeaderItem(0)
item.setText(_translate("Form", "x", None))
item = self.tableWidget.horizontalHeaderItem(1)
item.setText(_translate("Form", "y", None))
self.label_1.setText(_translate("Form", "Số liệu", None))
self.label_2.setText(_translate("Form", "Đồ thị", None))
self.lineEdit.setText(_translate("Form", "Bấm vào run để bắt đầu vẽ đồ thị", None))
self.pushButton_ok.setText(_translate("Form", "OK", None))
self.pushButton_exit.setText(_translate("Form", "Exit", None))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())