#ifndef CCARDLABEL_H
#define CCARDLABEL_H
#include <QLabel>
class CCardLabel:public QLabel
{
Q_OBJECT
public:
CCardLabel();
CCardLabel(const QLabel &);
bool eventFilter(QObject *object, QEvent *event);
signals:
void mouseClicked();
};
#endif // CCARDLABEL_H
------- ccardlabel.cpp ----------------------
#include <QtGui> #include "ccardlabel.h" #include <QString> #include <QLabel> CCardLabel::CCardLabel() { QLabel::QLabel("test2"); this->installEventFilter(this); } bool CCardLabel::eventFilter(QObject *object, QEvent *event) { if(event->type()==QMouseEvent::MouseButtonPress) { mouseClicked(); } return QWidget::eventFilter(object,event); }
댓글 없음:
댓글 쓰기