我已經Ubuntu 14.04
,C++
,QT
, 我會extend
類QPushbutton
,我會作出新的Slot
我做的:如何解決未定義的引用在C++中的vtable上QT
#include<QApplication>
#include<QDialog>
#include<QLabel>
#include <X11/Xlib.h>
#include<QVBoxLayout>
#include<iostream>
#include<QWidget>
#include<QPushButton>
#include <QThread>
#include <QGridLayout>
#include <QSplitter>
#include<QAbstractButton>
using namespace std;
class bot : public QPushButton {
Q_OBJECT;
public slots:
void txt() {
setText("hi");
}
};
int main(int a , char * b[])
{
QApplication application(a,b);
QPushButton *button = new QPushButton();
bot *l = new bot();
button->setFixedSize(100,100);
l->setText("sssssssssssssss");
QVBoxLayout *ll = new QVBoxLayout;
ll->addWidget(l);
ll->addWidget(button);
QWidget x ;
x.setLayout(ll);
x.show();
QObject::connect(button, SIGNAL(clicked()), l , SLOT(txt()));
return application.exec();
}
的問題是:
/home/user/untitled6/sd.cpp:18: error: undefined reference to `vtable for bot'
如何解決問題???
我file.pro是:
SOURCES += \
sd.cpp
QT += widgets
FORMS += \
form.ui
它仍然是同樣的問題! – SalamBoy
@SalamBoy嘗試清潔項目,請參閱編輯 –
我會的,\t \t 它保持了同樣的問題 – SalamBoy