1 自定义设置Qlabel文本颜色状态。 别的类可以进行类推
#ifndef QCOMPLEXLABEL_H
#define QCOMPLEXLABEL_H
#include <QObject>
#include <QWidget>
#include <QLabel>
class QComplexLabel : public QLabel
{
Q_OBJECT
Q_PROPERTY(QColor normalColor READ normalColor WRITE setNormalColor)
Q_PROPERTY(QColor errorColor READ errorColor WRITE setErrorColor)
Q_PROPERTY(QColor unknownColor READ unknownColor WRITE setUnknownColor)
public:
QComplexLabel(QWidget *parent = 0);
enum LabelState{
Normal = 0x00,
Error = 0x01,
Unknown = 0x02
};
void setNormalColor(const QColor &newColor) { m_normalColor = newColor; }
QColor normalColor() const { return m_normalColor; }
void setErrorColor(const QColor &newColor) { m_errorColor = newColor; }
QColor errorColor() const { return m_errorColor; }
void setUnknownColor(const QColor &newColor) { m_unkn