PDA

View Full Version : SIGNALS error....what's wrong?



nupul
5th May 2006, 08:41
This is the error I got after running the following commands:



qmake -project
qmake
make




moc_desktop.o: In function `MyDesktop:: progs_Clicked()':
/home/nupul/trials/2desktop/moc_desktop.cpp:93: multiple definition of
`MyDesktop:: progs_Clicked()'
desktop.o:/home/nupul/trials/2desktop/desktop.cpp:94: first defined here
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../../i586-suse-linux/bin/ld: Warning: size of symbol `MyDesktop:: progs_Clicked()' changed from 24 in desktop.o to 29 in moc_desktop.o
moc_desktop.o: In function `MyDesktop:: docs_Clicked()':
/home/nupul/trials/2desktop/moc_desktop.cpp:87: multiple definition of
`MyDesktop:: docs_Clicked()'
desktop.o:/home/nupul/trials/2desktop/desktop.cpp:87: first defined here
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../../i586-suse-linux/bin/ld: Warning: size of symbol `MyDesktop:: docs_Clicked()' changed from 24 in desktop.o to 29 in moc_desktop.o
moc_desktop.o: In function `MyDesktop::mycomp_Clicked()':
/home/nupul/trials/2desktop/moc_desktop.cpp:81: multiple definition of `MyDesktop::mycomp_Clicked()'
desktop.o:/home/nupul/trials/2desktop/desktop.cpp:80: first defined here
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../../i586-suse-linux/bin/ld: Warning: size of symbol `MyDesktop::mycomp_Clicked()' changed from 24 in desktop.o to 29 in moc_desktop.o
collect2: ld returned 1 exit status
make: *** [2desktop] Error 1


here is my header file format...



class MyDesktop : public QWidget
{
Q_OBJECT


private:

QPushButton *mycomp;
QPushButton *docs;
QPushButton *progs;
QPushButton *trash;

QBrush brush;
QPalette pal;

void getBackground();
void createButtons();
public:

MyDesktop();


signals:
void showMyComputerMenu();

protected:
void resizeEvent(QResizeEvent *event);

};

#endif



This is my constructor



MyDesktop::MyDesktop():QWidget(0)
{

setGeometry(100,100,400,400);
setWindowTitle("My Desktop");

getBackground();

createButtons();

connect(mycomp,SIGNAL(clicked()),this,SLOT(showMyC omputerMenu()));
}


and this is the signal



void MyDesktop::showMyComputerMenu()
{

qDebug("My computer signal activate");

}



Now the thing is this...if i change my signal: showMyComputerMenu to a slot, and run the aforementioned command sequence,
it works fine! No errors pop-up. I read through the docs, and it said qmake can take care of all the signals/slots etc. I have a feeling that I am missing out something...like running moc, But I am not able to understand at all what am I exactly supposed to do???

:confused:

Thanks

Nupul.

e8johan
5th May 2006, 09:09
From the messages it sounds as if there is some old code in a moc_...cpp-file. Try to run make clean and then make again.

wysota
5th May 2006, 09:09
Yeah, but showMyComputerMenu() is a slot and not a signal. You should declare it as a SLOT (you even use it as a slot in the connect() statement).

nupul
5th May 2006, 10:09
I realised my mistake after posting....

Both are signals in the connect statement. There is NO slot...any I will try what you said and post the comments

Thanks

nupul
5th May 2006, 10:17
I did what was told and ran 'make clean'

here is the output:



moc_desktop.o: In function `MyDesktop::showMyComputerMenu()':
/home/nupul/project/2desktop/moc_desktop.cpp:72: multiple definition of `MyDesktop::showMyComputerMenu()'
desktop.o:/home/nupul/project/2desktop/desktop.cpp:72: first defined here
/usr/lib/gcc/i586-suse-linux/4.0.2/../../../../i586-suse-linux/bin/ld: Warning: size of symbol `MyDesktop::showMyComputerMenu()' changed from 24 in desktop.o to 29 in moc_desktop.o
collect2: ld returned 1 exit status
make: *** [2desktop] Error 1

jacek
5th May 2006, 11:16
and this is the signal



void MyDesktop::showMyComputerMenu()
{

qDebug("My computer signal activate");

}


You can't implement signals --- moc does this for you.

nupul
5th May 2006, 11:53
Well Jacek seems that you raced me to the correct answer ;--)

You see, after posting and a few replies, I rummaged through the docs. I took the character-map example (it had signals) compiled it and voila...it worked....I read through the Signals and Slots section of the docs and they've mentioned it (not in bold...which i feel it should) that you don't implement signals!!

I was slightly taken aback, I grep-ed through the sources and found that you indeed don't implement them....I picked up my qt book and it was just mentioned as a one-liner that 'you don't implement them directly'

i loathe myself :crying: ............. i just completely overlooked this concept (to be honest...i never needed to implement signals till date, Qt's inbuilt classed provided me with enough resources. ;-) )

well I am glad that you people are there to help newbies like me....(my designation as an intermediate user has gone to the dumps :D)

I have highlighted the above in bold so that dimwits like me avoid making the same mistake and wonder :rolleyes: what the hell (actually the other 4 letter word ;)) is wrong!!!!!!!!!!!

Thanks a million.

Nupul

Jacek a special thanks to you though, you've always read through my code (you have, right? ) and given me accurate replies. You, jpn, CBM, wysota (always the first one to spot typographic errors in my post!...he catches those errors which i enter in my post by mistake!) deserve a special thanks...a treat to you guys....buy yourself a cuppa coffee!!!!!!!!!!!!!!!