equal
deleted
inserted
replaced
|
1 #ifndef HELPLABEL_H |
|
2 #define HELPLABEL_H |
|
3 |
|
4 #include <QLabel> |
|
5 #include <QMenu> |
|
6 |
|
7 class HelpLabel : public QLabel |
|
8 { |
|
9 Q_OBJECT |
|
10 public: |
|
11 HelpLabel(const QString &text) : QLabel(text) |
|
12 { setContextMenuPolicy(Qt::CustomContextMenu); |
|
13 connect(this,SIGNAL(customContextMenuRequested(const QPoint&)), |
|
14 this,SLOT(showMenu(const QPoint&))); |
|
15 } |
|
16 signals: |
|
17 void enter(); |
|
18 void reset(); |
|
19 private slots: |
|
20 void showMenu(const QPoint &p) |
|
21 { |
|
22 QMenu menu(this); |
|
23 QAction *a = menu.addAction(tr("Reset to default")); |
|
24 if (menu.exec(mapToGlobal(p))==a) |
|
25 { |
|
26 reset(); |
|
27 } |
|
28 } |
|
29 protected: |
|
30 void enterEvent( QEvent * event ) { enter(); QLabel::enterEvent(event); } |
|
31 }; |
|
32 |
|
33 #endif |