Run a method after switching to stackedWidget widget with setCurrentIndex()



  • Hello,
    project i'm working on consists of stacked widget and several widget form classes.
    I add "pages" in my stacked widget form class by creating objects of those form classes and adding them as widgets in stacked widget.
    .cpp constructor:
    homePage = new Page_home;
    operatorPage = new Page_operator;
    myStackedWidget->addWidget(homePage);
    myStackedWidget->addWidget(operatorPage);

    .h
    #include "page_home.h"
    #include "page_operator.h"
    in class:
    Page_home *homePage;
    Page_operator *operatorPage;

    switching between pages is done by subclassing QWidget class and connecting signal to slot with i.e. setCurrentIndex(2); method

    On homePage i'm reading data from SQLite DB and displaying it.
    On operatorPage i'm modifying DB data and switching back to homePage.

    Now the question is how do i automatically rerun my SQLite DB reading method after i switch to operatorPage(switching done with setCurrentIndex(2);)


  • Moderators

    @Eligijus You can override http://doc.qt.io/qt-5/qwidget.html#showEvent in your page widgets



  • Thanks just what i needed!


Log in to reply
 

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