PDA

View Full Version : سوال: undefined reference to vtable



oldboy
دوشنبه 12 اردیبهشت 1390, 23:00 عصر
سلام دوستان.
من تو اجرای برنامه ای که با کیوت نوشتم مشکل دارم. تو اینترنت (و همین سایت) هم سرچ کردم ولی هیچ کدوم از روش هایی که نوشته بودن مشکل منو حل نکرد.
برنامه هنوز کامل نیست. فقط برای امتحان کامپایلش میکردم که با این ارور (ها) مواجه شدم.

undefined reference to vtable...

اینم کد:


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include <QWorkspace>
#include <QSignalMapper>
#include <QMenuBar>
#include <QStatusBar>
#include <QAction>
#include <QMenu>

#include "documentwindow.h"

namespace ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT

private:
QWorkspace *workspace;
QSignalMapper *mapper;
QAction *closeAction;
QAction *newAction;
QAction *tileAction;
QAction *cascadeAction;
QAction *seperatorAction;

public slots:
void enableActions();

public:
MainWindow(QWidget *parent = 0);
~MainWindow();

void createActions();
void createMenus();
void createToolbars();

DocumentWindow *activeDocument();
};

#endif // MAINWINDOW_H



#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
this->setWindowTitle(tr("MDI"));

workspace=new QWorkspace(this);
this->setCentralWidget(workspace);

connect(this->workspace,SIGNAL(windowActivated(QWidget*)),this,S LOT(enableActions()));

mapper=new QSignalMapper(this);
connect(mapper,SIGNAL(mapped(QWidget*)),workspace, SLOT(setActiveWindow(QWidget*)));

createActions();
createMenus();
createToolbars();
statusBar()->showMessage(tr("Done."));

enableActions();
}

MainWindow::~MainWindow()
{

}

void MainWindow::createActions()
{
closeAction=new QAction(tr("&Close"),this);
closeAction->setShortcut(tr("Ctrl+W"));
closeAction->setStatusTip(tr("Close active form"));
connect(closeAction,SIGNAL(triggered()),workspace, SLOT(closeActiveWindow()));

tileAction=new QAction(tr("&Tile"),this);
tileAction->setStatusTip(tr("Tile windows"));
connect(tileAction,SIGNAL(triggered()),workspace,S LOT(tile()));

seperatorAction=new QAction(this);
seperatorAction->setSeparator(true);
}

void MainWindow::createMenus()
{
QMenu *menu=new QMenu(this);
menu=menuBar()->addMenu(tr("&File"));
// menu->addAction(newAction);
menu->addAction(seperatorAction);
menu->addAction(tileAction);
//menu->addAction(cascadeAction);
menu->addAction(seperatorAction);
menu->addAction(closeAction);

QMenu *windows=new QMenu(this);
windows=menuBar()->addMenu(tr("&Windows"));
}

void MainWindow::createToolbars()
{

}

DocumentWindow* MainWindow::activeDocument()
{
return qobject_cast<DocumentWindow*>(workspace->activeWindow());
}

void MainWindow::enableActions()
{
bool hasDoc=(activeDocument()!=0);

closeAction->setEnabled(hasDoc);
tileAction->setEnabled(hasDoc);
//cascadeAction->setEnabled(hasDoc);
// newAction->setEnabled(hasDoc);

seperatorAction->setVisible(hasDoc);

}




#ifndef DOCUMENTWINDOW_H
#define DOCUMENTWINDOW_H

#include <QWidget>
#include <QTextEdit>

namespace ui
{
class DocumentWindow;
}
class DocumentWindow : public QTextEdit
{
Q_OBJECT

public:
DocumentWindow(QWidget *parent=0);
~DocumentWindow();
};

#endif // DOCUMENTWINDOW_H



#include "documentwindow.h"

DocumentWindow::DocumentWindow( QWidget *parent):QTextEdit(parent)
{
this->setAttribute(Qt::WA_DeleteOnClose);
this->setWindowTitle(QString("%1 ").arg("Unnamed"));

connect(this->document(),SIGNAL(modificationChanged(bool)),this, SLOT(setWindowModified(bool)));
}

DocumentWindow::~DocumentWindow()
{

}

حامد مصافی
دوشنبه 12 اردیبهشت 1390, 23:25 عصر
فرمان qmake را اجرا کنید.

ژوپیتر
دوشنبه 12 اردیبهشت 1390, 23:26 عصر
به نظرم مشکلی نداره :متفکر:
GCC رو آپدیت کنی درست میشه. معمولا از این گیروگورا داره.

oldboy
سه شنبه 13 اردیبهشت 1390, 00:20 صبح
با تشکر از دوستان.
با اضافه کردن این یه خط به فایل پروژه مشکل حل شد.

CONFIG+=qt


کسی میدونه چرا خود Qt اینو اضافه نمی کنه؟