How to catch event right before QWidget is hidden?
-
@raven-worx no, the widget is in another widget (in layout). I have so-called 'main window' and a lot of widgets inside other widgets, organized in a hierarchy. These widgets can be hidden and i must handle that event somehow.
@VRonin thanks, but my problem is something different :)
-
@dream_captain said in How to catch event right before QWidget is hidden?:
These widgets can be hidden and i must handle that event somehow.
Then you need to show the message dialog before you would hide the (sub-)widget.
-
@dream_captain said in How to catch event right before QWidget is hidden?:
but it doesn't work the way i need
What is "the way you need"?
-
@raven-worx @VRonin imagine that user opens a subwidget and makes some changes in it (for example add text, set QCheckBox). Then he wants to leave this subwidget , so he clicks on another subwidget. I must hide first subwidget and show another subwidget. But before that i must check if there's changes that user made and show him a QMessageBox. It's easy to implement in a main widget via closeEvent(), but i can't do it in child-subwidget.
-
Hi,
you could use a QTabWidget and there connect to thevoid QTabWidget::currentChanged(int index)
signal.
-Michael. -
@m.sue said in How to catch event right before QWidget is hidden?:
you could use a QTabWidget and there connect to the void QTabWidget::currentChanged(int index) signal.
this helps how? The same issue remains using this approach.
The problem is that the hide event is the wrong approach for this. And also the currentChanged() signal is too late and also you still have no way to "cancel the hiding". -
Hi,
- With a tab widget there is no need to explictly hide sub-widgets, the tab widget just does it for you.
- @raven-worx: I did not understand that @dream_captain wants to stop the hiding. I suppose, though, that you could send a signal with singleshot timer with 0s that reverts the change of the tab widget in the slot connected to the currentChanged signal.
-Michael.
-
I think that my approach is completely wrong. The subwidget is hiding by the outside event (user clicks buttons, or some items in table). So i will connect click/activated signal) of these controls to the checkChanges() slot. It will let me check subwidget for changes and then call hide() from the outside.
-
@dream_captain said in How to catch event right before QWidget is hidden?:
I think that my approach is completely wrong. The subwidget is hiding by the outside event (user clicks buttons, or some items in table). So i will connect click/activated signal) of these controls to the checkChanges() slot. It will let me check subwidget for changes and then call hide() from the outside.
and thats the approach i was talking about and the only one available for you.
-
@raven-worx yeah, tried to implement the easy-approach. Thanks guys.