我想扩展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