[eaf] qt talán megmagyarázatlan linker error

  • From: "Ákos György Pfeff" <csopimaci@xxxxxxxxx>
  • To: eaf@xxxxxxxxxxxxx
  • Date: Tue, 3 Apr 2007 20:54:56 +0200

Kedves szaktársaim!

Az idegbaj kerülget, mert már órák óta nem haladok szinte semmit, és kezd
lejárni a szünetben az eaf-ra szánható időm.

A problémám az, hogy nem értem miért nem fordul le a progim. Ilyen egyszerű.
Írom a hibaüzenetet, és a kapcsolódó kódrészletet.

indexedbutton.o: In function `IndexedButton::setChoosenX(int)':
indexedbutton.cpp:(.text+0x48): undefined reference to
`IndexedButton::_choosenX'
indexedbutton.o: In function `IndexedButton::setChoosenY(int)':
indexedbutton.cpp:(.text+0x58): undefined reference to
`IndexedButton::_choosenY'
indexedbutton.o: In function `IndexedButton::getChoosenX()':
indexedbutton.cpp:(.text+0x62): undefined reference to
`IndexedButton::_choosenX'
indexedbutton.o: In function `IndexedButton::getChoosenY()':
indexedbutton.cpp:(.text+0x72): undefined reference to
`IndexedButton::_choosenY'
indexedbutton.o: In function `IndexedButton::setChoosen(bool)':
indexedbutton.cpp:(.text+0x88): undefined reference to
`IndexedButton::_isChoosen'
indexedbutton.o: In function `IndexedButton::getChoosen()':
indexedbutton.cpp:(.text+0x94): undefined reference to
`IndexedButton::_isChoosen'
indexedbutton.o: In function `IndexedButton::IndexedButton(int, int,
QWidget*)':
indexedbutton.cpp:(.text+0x107): undefined reference to
`IndexedButton::_isChoosen'
indexedbutton.o: In function `IndexedButton::IndexedButton(int, int,
QWidget*)':
indexedbutton.cpp:(.text+0x197): undefined reference to
`IndexedButton::_isChoosen'
indexedbutton.o: In function `IndexedButton::clickedSlot()':
indexedbutton.cpp:(.text+0x498): undefined reference to
`IndexedButton::_isChoosen'
indexedbutton.o:indexedbutton.cpp:(.text+0x4a7): more undefined references
to `IndexedButton::_isChoosen' follow

...a kódrészlet pedig:

IndexedButton::IndexedButton(int x, int y, QWidget *parent)
   : QPushButton(parent), _x(x), _y(y), _isolated(false)
{
   connect(this,SIGNAL(clicked()),this,SLOT(clickedSlot()));
   _isChoosen = false;
}

void IndexedButton::setChoosenX(int x)
{ _choosenX = x; }

void IndexedButton::setChoosenY(int y)
{ _choosenY = y; }

int IndexedButton::getChoosenX()
{ return _choosenX; }

int IndexedButton::getChoosenY()
{ return _choosenY; }

void IndexedButton::setChoosen(bool l)
{ _isChoosen = l; }

bool IndexedButton::getChoosen()
{ return _isChoosen; }

void IndexedButton::clickedSlot()
{
   if(isBall() == false)
   {
       if(_isChoosen){ emit moveChoosenBall(_x,_y); }
   }
   else
   {
       if(!_isChoosen)
       {
           setBallChoosen();
           setChoosen(true);
           setChoosenX(_x);
           setChoosenY(_y);
       }
       else
       {
           emit moveChoose(_x,_y);
       }
   }
}

...ehhez pedig a header:

#ifndef INDEXEDBUTTON_H
#define INDEXEDBUTTON_H

#include <QtGui>

class IndexedButton : public QPushButton
{
   Q_OBJECT

public:
   IndexedButton(int x, int y, QWidget *parent=0);
   int getX();
   int getY();
   bool isIsolated();
   void setIsolation(bool l);
   void setBallSmile();
   void setBallSad();
   void setBallChoosen();
   void putBall();
   void pickBall();
   bool isBall();

   static void setChoosenX(int x);
   static void setChoosenY(int y);
   static int getChoosenX();
   static int getChoosenY();
   static void setChoosen(bool l);
   static bool getChoosen();

private slots:
   void clickedSlot();

signals:
   void moveChoosenBall(int x, int y);
   void moveChoose(int x, int y);

private:
   static bool _isChoosen;
   static int _choosenX;
   static int _choosenY;
   int _x;
   int _y;
   bool _isolated;
};

#endif

Nagyon gyors segítségre lenne szükségem, amennyire ez lehetséges. Előre is
köszönet, és sok sikert mindenkinek!

--
Ákos

Other related posts: