thanks to all for u r reply
You are using the clicked() signal to connect to the slot hi(), but where is the button which after clicking will emit the signal ????
i have subclassed the QPushButton and in the connect function i am using this pointer .ie. the same pushbutton signal is connected to the slot.
The Q_OBJECT macro needs to be present in every class declaring a signal or a slot and moc has to be run on the header file.
it worked after declaring the class in the header file(with Q_OBJECT declaration in it) and defining the class in .cpp file.
but if i do both class declaration and definition in same file ,and even after including the Q_OBJECT macro i am getting the following error.
release
/main.
o(.
text+0x1a
): In function `push
::push(QWidget*)':make[1]: Leaving directory `/home/bala/workspace/gg'
: undefined reference to `vtable for push'
release/main.o(.text+0x22): In function `push::push(QWidget*)':
: undefined reference to `vtable for push'
release/main.o(.text+0x8a): In function `push::push(QWidget*)':
: undefined reference to `vtable for push'
release/main.o(.text+0x92): In function `push::push(QWidget*)':
: undefined reference to `vtable for push'
release/main.o(.text+0x3dc): In function `main':
: undefined reference to `vtable for push'
release/main.o(.text+0x3e5): more undefined references to `vtable for push' follow
collect2: ld returned 1 exit status
make[1]: *** [gg] Error 1
make: *** [release] Error 2
release/main.o(.text+0x1a): In function `push::push(QWidget*)':
make[1]: Leaving directory `/home/bala/workspace/gg'
: undefined reference to `vtable for push'
release/main.o(.text+0x22): In function `push::push(QWidget*)':
: undefined reference to `vtable for push'
release/main.o(.text+0x8a): In function `push::push(QWidget*)':
: undefined reference to `vtable for push'
release/main.o(.text+0x92): In function `push::push(QWidget*)':
: undefined reference to `vtable for push'
release/main.o(.text+0x3dc): In function `main':
: undefined reference to `vtable for push'
release/main.o(.text+0x3e5): more undefined references to `vtable for push' follow
collect2: ld returned 1 exit status
make[1]: *** [gg] Error 1
make: *** [release] Error 2
To copy to clipboard, switch view to plain text mode
i have defined the class only after the declaration , even then why do i need two files(header and source file, when there is a single class).
Bookmarks