質問: プリンター クラス 'apppprinter' を含むプログラムがありますが、コンパイルしようとすると次のエラーが発生します。
appprinter.cpp:(.text+0x105): undefined reference to `vtable for appprinter'
appprinter.cpp:(.text+0x10d): undefined reference to `vtable for appprinter'
appprinter.o: In function `appprinter::printIt()':
make: Leaving directory `/home/michael/projectOOI/HerkansingProjectOOI-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Release'
appprinter.cpp:(.text+0x17f): undefined reference to `appprinter::staticMetaObject'
appprinter.cpp:(.text+0x1e0): undefined reference to `appprinter::staticMetaObject'
appprinter.cpp:(.text+0x23d): undefined reference to `appprinter::staticMetaObject'
appprinter.cpp:(.text+0x3ab): undefined reference to `appprinter::staticMetaObject'
collect2: ld returned 1 exit status
ヘッダファイル:
#ifndef APPPRINTER_H
#define APPPRINTER_H
#include<QObject>
#include<QWidget>
#include <QMap>
#include <QComboBox>
#include <QCalendarWidget>
#include <QRadioButton>
#include <QString>
#include <QtGui>
#include "appointment.h"
class appprinter : public QWidget
{
Q_OBJECT
public:
appprinter(QWidget * parent = 0, int i = 0, int option = 0);
~appprinter(){}
void setList(QList<appointment> param) {goTo = param; printIt();}
void printIt();
public slots:
void goNext() {showIter++; this->close();appprinter * help = new appprinter(this,showIter);help->setList(goTo); help->show();}
void goPrev() {showIter--; this->close();appprinter * help = new appprinter(this,showIter);help->setList(goTo); help->show();}
private:
int showIter;
QList<appointment> goTo;
bool isUnder;
int opt;
};
#endif // appprinter_H
cpp ファイル:
#include "appprinter.h"
appprinter::appprinter(QWidget * parent, int i, int option)
: QWidget(parent)
{
showIter = i;
if (option == 0);//needs further building
}
void appprinter::printIt()
{
QList<appointment> list = goTo;
int i = showIter;
QPushButton * showNext = new QPushButton(tr("Next"));
connect(showNext,SIGNAL(clicked()),this,SLOT(goNext()));
QPushButton * showPrev = new QPushButton(tr("Previous"));
connect(showPrev,SIGNAL(clicked()),this,SLOT(goPrev()));
QPushButton * closer = new QPushButton(tr("Close"));
connect(closer,SIGNAL(clicked()),this,SLOT(close()));
QGridLayout * lay = new QGridLayout;
int counter = 0;
QLabel * pTitle = new QLabel;
QTextEdit * pDescription = new QTextEdit;
QLabel * pDeadline = new QLabel;
QLabel * pDeadlineTime = new QLabel;
QLabel * pPriority = new QLabel;
QLabel * pStatus = new QLabel;
QLabel * emptyList = new QLabel(tr("No search results!"));
if (list.count() != 0)
{
pTitle->setText(list[i].ShowTitle());
pDescription->setText(list[i].ShowDescription());
pDeadline->setText(list[i].ShowDate().toString());
pDeadlineTime->setText(list[i].ShowStart().toString());
if (i+1 >= list.count())
showNext->hide();
else
showNext->show();
if (i <= 0)
showPrev->hide();
else
showPrev->show();
lay->addWidget(pTitle,counter++,0);
lay->addWidget(pDescription,counter++,0);
lay->addWidget(pDeadline,counter++,0);
lay->addWidget(pDeadlineTime,counter++,0);
lay->addWidget(pPriority,counter++,0);
lay->addWidget(pStatus,counter++,0);
lay->addWidget(showPrev,counter,0,Qt::AlignLeft);
lay->addWidget(showNext,counter,0,Qt::AlignRight);
lay->addWidget(closer,++counter,0,Qt::AlignCenter);
this->setFixedHeight(320);
}
else
{
lay->addWidget(emptyList,0,0);
lay->addWidget(closer,1,0,Qt::AlignCenter);
this->setFixedHeight(240);
}
setLayout(lay);
if (list.count() != 0)
setWindowTitle(list[i].ShowTitle());
}
誰かが解決策を知っていますか??