You must use the setCurrentIndex(), currentIndex() and count() methods of QStackedWidget.