关于pyqt6设置右对齐居中的示例


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)

声明:一代明君的小屋|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - 关于pyqt6设置右对齐居中的示例


欢迎来到我的小屋