Question: I would like to ask about QStackedLayout.
Now, I have a several widgets added to the QStackedLayout
And I want to do sth like that:
When user switch to Page X, refresh Page X.

How can I do that?
I have a custom code that I want to run when it refreshes
Thank You very much

Answer: 
All "pages" are QWidget based classes. If your widgets does not paint itself properly you need to check your widget's code. Generally, while switching pages, visible widget repaint itself. If your widgets does not handle some events you can see glitches.

Anyway, if you want to force a repaint for your "page" you need to call [`QWidget::update()`](http://doc.qt.nokia.com/latest/qwidget.html#update) or (bruteforce method) [`QWidget::repaint()`](http://doc.qt.nokia.com/latest/qwidget.html#repaint).
In my opinion, the best way to handle this situation is through inheritance. Create a class that derives from `QWidget` that has a virtual update function. Use that as a base class for every page of your stacked widget. In your class that contains the stacked widget, connect a slot to the [`currentChanged(int index)`](http://doc.qt.nokia.com/latest/qstackedwidget.html#currentChanged) signal of the stacked widget. In that slot, get the current widget, [`qobject_cast`](http://doc.qt.nokia.com/latest/qobject.html#qobject_cast) it to your base type, and (if successful) call the update function on it.

Each class that is a page in your stacked widget should then override the update function and use it to update its information as necessary.