Results 1 to 3 of 3

Thread: Linker errors!!

  1. #1
    Join Date
    Feb 2006
    Posts
    42
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Linker errors!!

    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

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Linker errors!!

    comment Q_OBJECT and try

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Linker errors!!

    void QToolButton::mousePressEvent(QMouseEvent *e)
    -> void ToolButton::mousePressEvent(QMouseEvent *e)

    void QToolButton::leaveEvent(QEvent *e)
    -> void ToolButton::leaveEvent(QEvent *e)

    - call base class constructor!
    - I also suggest you to get used to a habit of adding parent widget as ctor parameter..
    J-P Nurmi

Similar Threads

  1. Qt4 Lib -- Linker Problems Qt4/OpenGL
    By Jackson.Shredder in forum Qt Programming
    Replies: 6
    Last Post: 19th January 2009, 18:22
  2. Vtable linker error
    By jhearon in forum Qt Programming
    Replies: 3
    Last Post: 22nd July 2007, 17:31
  3. Example QtUiTools linker error
    By phillies in forum Newbie
    Replies: 1
    Last Post: 26th June 2007, 21:27
  4. Linker Errors
    By MarkoSan in forum Qt Programming
    Replies: 5
    Last Post: 7th March 2006, 18:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.