Layouts are strictly for arrangement. You must not use them for user interaction. Create you own label class instead:
//header
{
Q_OBJECT
public:
MyLabel
(const QString & text,
QWidget * parent
= 0, Qt
::WindowFlags f
= 0);
~MyLabel();
signals:
void clicked();
protected:
}
//cpp
MyLabel
::MyLabel(const QString & text,
QWidget * parent
= 0, Qt
::WindowFlags f
= 0){
}
MyLabel::~MyLabel()
{
}
{
emit clicked();
}
//header
class MyLabel : public QLabel
{
Q_OBJECT
public:
MyLabel(const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0);
~MyLabel();
signals:
void clicked();
protected:
void mousePressEvent(QMouseEvent*);
}
//cpp
MyLabel::MyLabel(const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0)
:QLabel(text, parent, f)
{
}
MyLabel::~MyLabel()
{
}
void MyLabel::mousePressEvent(QMouseEvent*)
{
emit clicked();
}
To copy to clipboard, switch view to plain text mode
All you have to do is to connect the clicked signal of each label to some slot(s).
Bookmarks