-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hider.h
42 lines (33 loc) · 769 Bytes
/
Hider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef HIDER_H
#define HIDER_H
#include <QEvent>
#include <QPaintEvent>
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QGridLayout>
#include <QDialogButtonBox>
#include <QApplication>
class Hider : public QObject
{
Q_OBJECT
public:
Hider(QObject *parent = 0) : QObject(parent){}
bool eventFilter(QObject *, QEvent *ev){
return ev->type() == QEvent::Paint;
}
void hide(QWidget *wdg){
wdg->installEventFilter(this);
wdg->update();
}
void unhide(QWidget *wdg){
wdg->removeEventFilter(this);
wdg->update();
}
Q_SLOT void hideWidget()
{
QObject *s = sender();
if(s->isWidgetType()) { hide(qobject_cast<QWidget*>(s));}
}
};
#endif // HIDER_H