我想擴展QLine類以包含顏色屬性。我使用QCreator爲新類QLineColor創建代碼,並在公共數據中添加了屬性char color = 0。這裏是由QCreator生成的代碼。Qt QLine類擴展
更新:根據關於QObject的響應修改。但現在我得到了一些其他錯誤:
/home/james/qtsdk-2010.05/qt/include/QtCore/qobject.h:309: error:
‘QObject::QObject(const QObject&)’ is private
within this context
and it lists several qt/include directories
文件:QLineColor.h
#ifndef QLINECOLOR_H
#define QLINECOLOR_H
#include <QLine>
#include <QObject>
class QLineColor : public QObject, public QLine
{
Q_OBJECT
public:
explicit QLineColor(int x1, int y1, int x2, int y2, char color);
char color;
};
#endif // QLINECOLOR_H
文件:qlinecolor.cpp
#include "qlinecolor.h"
QLineColor::QLineColor(int x1, int y1, int x2, int y2, char color) :
QLine(x1, y1, x2, y2)
{
color = 0;
}
哈哈thx ... QtCreator有問題... – user623879 2011-03-11 08:53:33