I'm trying to make simple custom widget in Qt(named DingButton, inherited from QPushButton). I made it. It is seen in Qt Designer. But when I compile project(named DingDemo) which includes this custom widget I get an error:
undefined reference to `DingButton::DingButton(QWidget*)
which points to the next code in ui_DingDemo.h:
class Ui_DingDemo
{
public:
DingButton *dingbutton;
void setupUi(QWidget *DingDemo)
{
if (DingDemo->objectName().isEmpty())
DingDemo->setObjectName(QString::fromUtf8("DingDemo"));
DingDemo->resize(226, 97);
dingbutton = new DingButton(DingDemo); //<---------error here
I've searched the Internet and tried to follow next instruction:
add the line:
LIBS += -Wl,-rpath,/usr/local/qt4/plugins/designer -L/usr/local/qt4/plugins/designer -l libding-button-plugin.so
to .pro file
But that wasn't successful.
Why this happens? And how to get through this?
Please, help me
ding-button-plugin.pro
CONFIG += plugin release designer
TEMPLATE = lib
TARGET = $$qtLibraryTarget($$TARGET)
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
INCLUDEPATH += .
LIBS += -Wl,-rpath,/usr/local/qt4/plugins/designer -L/usr/local/qt4/plugins/designer -l libding-button-plugin.so
HEADERS += DingButton.h DingButtonPlugin.h
SOURCES += DingButton.cpp DingButtonPlugin.cpp
EDIT: DingButton::DingButton(QWidget* ) is implemented
You have to implement this constructor which is being called in the line where the error occurs.
DingButton(QWidget *widget = 0);//In your DingButton class
DingButton::DingButton(QWidget *widget) : QWidget(widget) //In your .cpp
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With