Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Run a method after switching to stackedWidget widget with setCurrentIndex()
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 763 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Eligijus
    wrote on last edited by
    #1

    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);)

    jsulmJ 1 Reply Last reply
    0
    • E Eligijus

      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);)

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • E Offline
        E Offline
        Eligijus
        wrote on last edited by
        #3

        Thanks just what i needed!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved