I've created a custom plugin and put this on my designer widget box, after I created a new form (widget) for an application to test my plugin...
I just drop my custom plugin in a form widget and wrote the main.cpp file
#include <QApplication>
#include <QDialog>
#include "ui_form.h"
int main(int argc,char *argv[]) {
Ui::Form ui;
ui.setupUi(tela);
tela->show();
return app.exec();
}
#include <QApplication>
#include <QDialog>
#include "ui_form.h"
int main(int argc,char *argv[]) {
QApplication app(argc,argv);
QDialog* tela = new QDialog;
Ui::Form ui;
ui.setupUi(tela);
tela->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
But when I compile the source code, I got the follwing message:
g++ -c -pipe -march=pentium4 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/doc/qt-4.1.1/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
g++ -o teste_plugin_2 main.o -L/usr/lib/qt4 -lQtGui -L/usr/lib/mysql -L/usr/lib/qt4 -L/usr/lib -laudio -lXt -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXcursor -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -ldl -lpthread
main.o: In function `main':
main.cpp:(.text+0x1a7): undefined reference to `MyButtons::MyButtons(QWidget*)'
collect2: ld returned 1 exit status
make: ** [teste_plugin_2] Erro 1
Here is my class definition (because I'm using a plugin I have to files mybuttons.h and mybuttonplugin.h, but I think the problem is on mybutton.h)
#ifndef MYBUTTONS_H
#define MYBUTTONS_H
#include <QPushButton>
#include <QHBoxLayout>
#include <QWidget>
#include <QtDesigner/QDesignerExportWidget>
class QDESIGNER_WIDGET_EXPORT MyButtons
: public QWidget {
Q_OBJECT
public:
protected:
void setB1Text(const QString&);
void setB2Text(const QString&);
signals:
void B1Clicked();
void B2Clicked();
private:
};
#endif
#ifndef MYBUTTONS_H
#define MYBUTTONS_H
#include <QPushButton>
#include <QHBoxLayout>
#include <QWidget>
#include <QtDesigner/QDesignerExportWidget>
class QDESIGNER_WIDGET_EXPORT MyButtons : public QWidget {
Q_OBJECT
public:
MyButtons(QWidget *parent=0);
protected:
void setB1Text(const QString&);
void setB2Text(const QString&);
const QString getB1Text() const;
const QString getB2Text() const;
signals:
void B1Clicked();
void B2Clicked();
private:
QPushButton* B1;
QPushButton* B2;
QHBoxLayout* layout;
};
#endif
To copy to clipboard, switch view to plain text mode
And the constructor implementation
layout->addWidget(B1);
layout->addWidget(B2);
connect (B1, SIGNAL(clicked()), this, SIGNAL(B1Clicked()));
connect (B2, SIGNAL(clicked()), this, SIGNAL(B2Clicked()));
}
MyButtons::MyButtons(QWidget* parent) : QWidget(parent) {
B1 = new QPushButton();
B2 = new QPushButton();
layout = new QHBoxLayout(this);
layout->addWidget(B1);
layout->addWidget(B2);
connect (B1, SIGNAL(clicked()), this, SIGNAL(B1Clicked()));
connect (B2, SIGNAL(clicked()), this, SIGNAL(B2Clicked()));
}
To copy to clipboard, switch view to plain text mode
I'm using qt 4.1.1 (gcc 3.4.0) on a x86 machine.
Bookmarks