Code::Blocks Forums

User forums => Help => Topic started by: alfre on November 02, 2007, 09:39:28 pm

Title: C::B+QT "undefined reference to vtable"
Post by: alfre on November 02, 2007, 09:39:28 pm
    I'm sorry my english, I speak spanish.

     I use C::B + Qt on Linux,
     when I try to do my own public slots method I got an Error :  "undefined reference to vtable"  WHY???

                                                               THANKS FOR YOU HELP!!!!!!
HERE the code:

#ifndef COUNTER_H_INCLUDED
#define COUNTER_H_INCLUDED

#include <QtGui>   //include todo

class Counter : public QWidget
 {
    Q_OBJECT

 private:
     QPushButton * but1;
     QPushButton * but2;

 public :
     Counter() : QWidget()
   {
          
         but1 = new QPushButton("the 1", this);
         but1->setGeometry(10,50,100,50);
        
         but2 = new QPushButton("the 2", this);
    but2->setGeometry(200,50,100,50);

   QObject::connect(but1, SIGNAL(clicked()), this, SLOT(Esconder2()));
      }

public slots:
       void Esconder2(){ but2->hide(); }

 };

#endif // COUNTER_H_INCLUDED
Title: Re: C::B+QT "undefined reference to vtable"
Post by: orel on November 03, 2007, 04:21:55 pm
This can arrive when you didn't declare and implement a destructor (virtual or not) and you defined your own contructor. I am not at home to test that with your code but, hope it helps !
Title: Re: C::B+QT "undefined reference to vtable"
Post by: MortenMacFly on November 05, 2007, 09:47:09 am
It may also be that you mixed object files compiled with- and without the debug switch. Try a re-build.
With regards, Morten.
Title: Re: C::B+QT "undefined reference to vtable"
Post by: alfre on November 05, 2007, 04:53:40 pm
nothing at all., but thanks., and if you have other ideas., write pleace.....
                                                                                                      regards alfre
Title: Re: C::B+QT "undefined reference to vtable"
Post by: Mc.Michael on November 05, 2007, 08:10:05 pm


#ifndef COUNTER_H_INCLUDED
#define COUNTER_H_INCLUDED

#include <QtGui>   //include todo





try
#ifndef COUNTER_H_INCLUDED
#define COUNTER_H_INCLUDED

#include <QtGui/QWidget>
#include <QtGui/QPushButton>

or
#ifndef COUNTER_H_INCLUDED
#define COUNTER_H_INCLUDED

#include <QWidget>
#include <QPushButton>

if you use your own slots, read info about MOC utility and add to Pre-Build step moc-info file generation

my bachelor project : mingw gcc 3.4.5 & Qt 4.3.1 with CB project files on win2k3
Code
http://www.download.mware.ru/mwOCR.v.0.0.1.24.7z



/* I'm sorry my english, I speak ukranian and russian.*/

in attached test.7z your code. work on win2k3sp2 & qt 4.3.2 & vista platform sdk

[attachment deleted by admin]
Title: Re: C::B+QT "undefined reference to vtable"
Post by: alfre on November 06, 2007, 10:13:56 pm
nothing again :(

   Mc.Michael, if you have done your own method slots, please sent to me the code, to try with it. thanks you
Title: Re: C::B+QT "undefined reference to vtable"
Post by: alfre on November 08, 2007, 09:26:50 pm
 :D :D :D Its work .I put in the console  dir make clean and all ok.... Thanks for your time