25
One solution is, you can override QWidget::showEvent() and QWidget::hideEvent() function in your widget (documentation). And then emit you custom signal and catch in a slot in the respective object. For example..
void MyWidget::hideEvent(QHideEvent *)
{
// 'false' means hidden..
emit widgetVisibilityChanged(false);
}
void MyWidget::showEvent(QShowEvent *)
{
// 'true' means visible..
emit widgetVisibilityChanged(true);
}
Now if you cannot override your widget, you can also receive above events in its parent widget using QObject::installEventFilter ( QObject * filterObj ) and QObject::eventFilter ( QObject * watched, QEvent * event ) combination (documentation and example).