helplabel.h
Go to the documentation of this file.
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
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
def connect(nxgraph, k1, k2, p1=0, p2=0, kwds)
Definition: graph.py:30
void showMenu(const QPoint &p)
Definition: helplabel.h:20
void enterEvent(QEvent *event)
Definition: helplabel.h:30
const double a
p
Definition: test.py:223
HelpLabel(const QString &text)
Definition: helplabel.h:11
void enter()
Event finding and building.
void reset()