PyQt5直接用代码布局 -让按钮永远在右下角(addStretch)
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QHBoxLayout, QPushButton, QMessageBox, QApplication, QVBoxLayout, QWidget, \
QLabel
'''
PyQt5直接用代码布局 -让按钮永远在右下角(addStretch)
'''
class RightBottomButtonDemo(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
# 设置定位和左上角坐标
self.setGeometry(300, 300, 360, 260)
# 设置窗口标题
self.setWindowTitle('让按钮永远在右下角(addStretch) 的演示')
# 设置窗口图标
# self.setWindowIcon(QIcon('../web.ico'))
OKBtn = QPushButton('确定')
cancelBtn = QPushButton('取消')
# 水平布局
hbox = QHBoxLayout()
hbo