Skip to content

self.layerMain().setPage(1) 不改变侧边栏显示 #275

@Lvting-Road

Description

@Lvting-Road

如题,实测加上 self.layerMain().setPage(1) 后虽然可以跳转到第 2 个页面,但没有在侧边栏上显示选中第 2 个页面。

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from siui.components.page import SiPage
from siui.components.widgets import *
from siui.templates.application.application import SiliconApplication

class HomePage(SiPage):
    """主页"""
    def __init__(self, parent, x):
        super().__init__(parent)
        self.label = SiLabel(x, self)

class MainWindow(SiliconApplication):
    """程序主窗口"""
    def __init__(self):
        super().__init__(None)
        self.setFixedSize(1200, 700)
        lm = self.layerMain()
        lm.addPage(HomePage(self, '1'), icon=SiGlobal.siui.iconpack.get('ic_fluent_home_filled'), hint='主页')
        lm.addPage(HomePage(self, '2'), icon=SiGlobal.siui.iconpack.get('ic_fluent_home_filled'), hint='主页2')
        lm.setPage(1)                               # 设置为第 0 个页面(主页)
        SiGlobal.siui.reloadAllWindowsStyleSheet()  # 应用窗口样式

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    app.exec()

环境为Windows11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions