Here is a simple Qt code I have written to study signals and slots concept :-
#include<QObject>
Q_OBJECT
public:
A(){val=0;}
public slots:
void changeval(int n){
val=n;
emit changed(val);
}
signals:
void changed(int n);
private:
int val;
};
int main()
{
A l,m;
}
#include<QObject>
class A : public QObject{
Q_OBJECT
public:
A(){val=0;}
public slots:
void changeval(int n){
val=n;
emit changed(val);
}
signals:
void changed(int n);
private:
int val;
};
int main()
{
A l,m;
}
To copy to clipboard, switch view to plain text mode
I followed the following to "make" it
1.qmake -project
2.qmake
3.make
And at the last phase, I got an error as :
communicate.o: In function `main':
communicate.cpp:(.text+0x2d): undefined reference to `vtable for A'
communicate.cpp:(.text+0x4d): undefined reference to `vtable for A'
communicate.cpp:(.text+0x68): undefined reference to `vtable for A'
communicate.cpp:(.text+0x8d): undefined reference to `vtable for A'
collect2: ld returned 1 exit status
make: *** [firstapp] Error 1
communicate.o: In function `main':
communicate.cpp:(.text+0x2d): undefined reference to `vtable for A'
communicate.cpp:(.text+0x4d): undefined reference to `vtable for A'
communicate.cpp:(.text+0x68): undefined reference to `vtable for A'
communicate.cpp:(.text+0x8d): undefined reference to `vtable for A'
collect2: ld returned 1 exit status
make: *** [firstapp] Error 1
To copy to clipboard, switch view to plain text mode
I don't have no idea how does this happen. Can you please help me out?
Bookmarks