开始学QT了
我自定义了一个QMyLabel,并且参照C++ GUI Programming with QT 4, second Edition -> Charpter 5 -> Subclassing QWidget上的内容,加了一个属性,编译后,为什么在properties editor中没有显示出我自定的属性呢,以下是我的头文件,请大家指教。
#ifndef MYLABEL_H_
#define MYLABEL_H_
#include <qlabel>
class QMyLabel : public QLabel
{
Q_OBJECT
Q_PROPERTY(bool useColorDialog READ UseColorDialog WRITE SetUseColorDialog)
signals:
void ColorChanged( QColor newColor );
public:
QMyLabel( QWidget* aParent = 0 );
inline bool UseColorDialog()const
{
return useColorDialog;
};
inline void SetUseColorDialog( bool aIsUseColorDialog )
{
useColorDialog = aIsUseColorDialog;
};
protected:
void mousePressEvent(QMouseEvent *);
private:
bool useColorDialog;
};