Results 1 to 7 of 7

Thread: SIGNALS error....what's wrong?

  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry SIGNALS error....what's wrong?

    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...

    Qt Code:
    1. class MyDesktop : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5.  
    6. private:
    7.  
    8. QPushButton *mycomp;
    9. QPushButton *docs;
    10. QPushButton *progs;
    11. QPushButton *trash;
    12.  
    13. QBrush brush;
    14. QPalette pal;
    15.  
    16. void getBackground();
    17. void createButtons();
    18. public:
    19.  
    20. MyDesktop();
    21.  
    22.  
    23. signals:
    24. void showMyComputerMenu();
    25.  
    26. protected:
    27. void resizeEvent(QResizeEvent *event);
    28.  
    29. };
    30.  
    31. #endif
    To copy to clipboard, switch view to plain text mode 

    This is my constructor

    Qt Code:
    1. MyDesktop::MyDesktop():QWidget(0)
    2. {
    3.  
    4. setGeometry(100,100,400,400);
    5. setWindowTitle("My Desktop");
    6.  
    7. getBackground();
    8.  
    9. createButtons();
    10.  
    11. connect(mycomp,SIGNAL(clicked()),this,SLOT(showMyComputerMenu()));
    12. }
    To copy to clipboard, switch view to plain text mode 

    and this is the signal

    Qt Code:
    1. void MyDesktop::showMyComputerMenu()
    2. {
    3.  
    4. qDebug("My computer signal activate");
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

    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???



    Thanks

    Nupul.
    Last edited by nupul; 5th May 2006 at 08:46.

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SIGNALS error....what's wrong?

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: SIGNALS error....what's wrong?

    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).

  4. #4
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Arrow Re: SIGNALS error....what's wrong?

    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

  5. #5
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: SIGNALS error....what's wrong?

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SIGNALS error....what's wrong?

    Quote Originally Posted by nupul
    and this is the signal

    Qt Code:
    1. void MyDesktop::showMyComputerMenu()
    2. {
    3.  
    4. qDebug("My computer signal activate");
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 
    You can't implement signals --- moc does this for you.

  7. #7
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Cool Re: SIGNALS error....what's wrong?

    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 ............. 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 )

    I have highlighted the above in bold so that dimwits like me avoid making the same mistake and wonder 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!!!!!!!!!!!!!!!

Similar Threads

  1. Signals are delayed on X11?
    By Cruz in forum Qt Programming
    Replies: 13
    Last Post: 18th February 2009, 12:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.