Categories
python

PyQt5 QStackedWidget 使用方法

initialize sub component

self.Stack = QStackedWidget (self)
self.Stack.addWidget (self.stack1)
self.Stack.addWidget (self.stack2)
self.Stack.addWidget (self.stack3)

事件触发关联

self.leftlist.currentRowChanged.connect(self.display)

切换页面

def display(self,i):
    self.Stack.setCurrentIndex(i)

Leave a Reply