关于pyqt6设置右对齐居中的示例 最后更新时间:2025年09月28日 ```python class InfoLayout(QVBoxLayout): def __init__(self): super().__init__() # 空白窗口 space_window = QWidget() space_window.setFixedHeight(100) # 英文标题 english_title_window = QWidget() english_title_window.setFixedHeight(80) english_title_window.setContentsMargins(0,0,0,-80) english_title_window.setStyleSheet("") ethl = QHBoxLayout() icon = QLabel("●") icon.setFont(QFont("SimHei", 8, QFont.Weight.Bold)) icon.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter) # 设置右对齐垂直居中 icon.setStyleSheet("color: #4CC9F0;") system_name = QLabel("SECURE ACCESS") system_name.setFont(QFont("SimHei", 24, QFont.Weight.DemiBold)) system_name.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter) # 设置左对齐垂直居中 system_name.setStyleSheet("color: white;") ethl.setStretch(0,1) ethl.setStretch(1,3) ethl.addWidget(icon) ethl.addWidget(system_name) english_title_window.setLayout(ethl) # 中文标题 title_window = QWidget() title_window.setFixedHeight(80) thl = QHBoxLayout() space_label = QLabel("") space_label.setAlignment(Qt.AlignmentFlag.AlignRight) title_label = QLabel("安全认证系统") title_label.setFixedHeight(80) title_label.setFont(QFont("SimHei", 18, QFont.Weight.Bold)) title_label.setAlignment(Qt.AlignmentFlag.AlignLeft) title_label.setStyleSheet("color: #8B98A9; margin: 20px;") thl.addWidget(space_label) thl.addWidget(title_label) title_window.setLayout(thl) # 产品介绍 piw = ProjectIntraduce() # 组合窗口 self.addWidget(space_window) self.addWidget(english_title_window) self.addWidget(title_window) self.addWidget(piw,1) ```
Comments | NOTHING