Access to QStackedWidget's widget

  • I've created a QStackedWidget and added some widget into ( Qpushbutton, and so on ). How can i access to them?
    I could understand that using : ui->stackedwidget->widget(0) return a QWidget* which is the first page ( index : 0 ), and now? How can i reach the QPushbutton and so on?

  • If you create the QStackedWidget with Designer (or the designer component in Creator), you have access to all widgets via the ui member of your class. No need to call widget(0) then.

  • And basically, the same goes even if you did not use designer. In that case, you simply keep track of the objects you need later on by keeping a pointer to them around as a member of your class.

  • It was SO EASY, i thought that the widget were located under ui->stackedwidget->bla bla, indeed they are simply under ui->mywidget. So easy!
    Huge thanks!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.