Hi all,
I just wanted to subclass QToolButton, but while building this sample I am getting strange linker errors!!. Can some body explain why this is happening, here is the code I have written,
//toolbutton.h
#ifndef TOOL_BUTTON
#define TOOL_BUTTON
#include <QToolButton>
#include <QEvent>
#include <QMouseEvent>
class ToolButton: public QToolButton
{
Q_OBJECT
public:
ToolButton();
protected:
void mousePressEvent(QMouseEvent *e);
void enterEvent(QEvent * e);
void leaveEvent(QEvent * e);
};
#endif
//toolbutton.cpp
#include "toolbutton.h"
ToolButton::ToolButton(){}
void ToolButton::enterEvent(QEvent * e)
{
}
void QToolButton::mousePressEvent(QMouseEvent *e)
{
}
void QToolButton::leaveEvent(QEvent *e)
{
}
//main.cpp
#include <QtGui>
#include "toolbutton.h"
int main(int argc,char *argv[])
{
QApplication myapp(argc,argv);
QWidget *wid= new QWidget;
ToolButton *mybutton = new ToolButton;
ToolButton *mybutton1 = new ToolButton;
mybutton1->setAutoRaise(1);
mybutton->setAutoRaise(1);
QHBoxLayout *layout= new QHBoxLayout;
layout->addWidget(mybutton);
mybutton->setToolTip("hi this is button");
layout->addWidget(mybutton1);
wid->setLayout(layout);
wid->show();
return myapp.exec();
}
I am using Qt 4.0.1, here is the linker error I got,
/usr/bin/ld: Dwarf Error: Invalid or unhandled FORM value: 14.
/usr/bin/ld: Dwarf Error: Could not find abbrev number 1843.
moc_toolbutton.o(.gnu.linkonce.d._ZTV10ToolButton+ 0x50): undefined reference to `ToolButton::mousePressEvent(QMouseEvent*)'
moc_toolbutton.o(.gnu.linkonce.d._ZTV10ToolButton+ 0x78): undefined reference to `ToolButton::leaveEvent(QEvent*)'
collect2: ld returned 1 exit status
make: *** [toolbutton] Error 1
Can some body please help?
Thanks in Advance,
Seema Rao
Bookmarks