TemplateHandlerクラスを書き込むときに、私はTemplateHandler.h(ヘッダ用)とTemplateHandler.cpp(宣言用)を使用します。同様Qt forward宣言でエラーが発生する
// Templatehandler.h
#ifndef TEMPLATEHANDLER_H
#define TEMPLATEHANDLER_H
#include <QObject> // Forward declaration of QObject generates error
class QListView; // Forward declarations
class QTextEdit;
class QModelIndex;
class QStringListModel;
class TemplateHandler : public QObject
{
Q_OBJECT
public:
TemplateHandler(QListView *view, QTextEdit *textEdit, QObject *parent);
virtual ~TemplateHandler();
private:
QTextEdit *mTextEdit;
QStringListModel *mModel;
};
#endif
とソース
#include "templatehandler.h"
#include <QListView> // Inclusion of lib
#include <QTextEdit>
#include <QObject>
#include <QStringListModel>
TemplateHandler::TemplateHandler(QListView *view, QTextEdit *textEdit, QObject *parent) : QObject(parent), mTextEdit(textEdit)
{
mModel = new QStringListModel(this);
QStringList templates;
templates << "<html>" << "</html>" << "<body>" << "</body>";
mModel->setStringList(templates);
view->setModel(mModel);
connect(view, SIGNAL(clicked(const QModelIndex&)), SLOT(insertText(const QModelIndex&)));
}
TemplateHandler::~TemplateHandler() {
// TODO Auto-generated destructor stub
}
しかし、この場合にはQObjectをの前方宣言でエラーが発生したが、しかし、残りはオーケーです。私はそれについていくつかの助けが必要です。
このエラー??? – UmNyobe