老师原课件下载地址:
有积分的朋友,支持下我,打赏也OK。
不下载也可以,我每节课会吧代码贴出来
视频链接
课程重点
前面老师讲过这个内容,这里我就不重复做了,相关课程看下面这个
https://editor.csdn.net/md/?articleId=105924380
代码位置
完整代码
'''
QLabel与伙伴控件
mainLayout.addWidget(控件对象,rowIndex,columnIndex,row,column)
'''
from PyQt5.QtWidgets import *
import sys
class QLabelBuddy(QDialog) :
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setWindowTitle('QLabel与伙伴控件')
nameLabel = QLabel('&Name',self)
nameLineEdit = QLineEdit(self)
# 设置伙伴控件
nameLabel.setBuddy(nameLineEdit)
passwordLabel = QLabel('&Password',self)
passwordLineEdit = QLineEdit(self)
# 设置伙伴控件
passwordLabel.setBuddy(passwordLineEdit)
btnOK = QPushButton('&OK')
btnCancel = QPushButton('&Cancel')
mainLayout = QGridLayout(self)
mainLayout.addWidget(nameLabel,0,0)
mainLayout.addWidget(nameLineEdit,0,1,1,2)
mainLayout.addWidget(passwordLabel,1,0)
mainLayout.addWidget(passwordLineEdit,1,1,1,2)
mainLayout.addWidget(btnOK,2,1)
mainLayout.addWidget(btnCancel,2,2)
if __name__ == '__main__':
app = QApplication(sys.argv)
main = QLabelBuddy()
main.show()
sys.exit(app.exec_())
遇到的问题
没问题,简直麻烦,点击个鼠标就搞定的事情,我并不想知道纯代码和原理!!谢谢
改写效果展示
改写注意点
这节太简单了,懒的写了,直接下一课程。