Я пытаюсь расширить класс QLine, чтобы включить атрибут цвета.Я использовал QCreator для создания кода для нового класса QLineColor и просто добавил атрибут char color = 0 в общедоступные данные.Вот код, сгенерированный QCreator.
ОБНОВЛЕНИЕ: Изменено в соответствии с ответом о 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;
}