Results 1 to 3 of 3

Thread: slots and signals don't seem to be recognized

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default slots and signals don't seem to be recognized

    Hello all.

    I'm very new to Qt but I'm extremely impressed with several aspects of it, especially the documentation.
    I'm not an expert programmer (more of a hobbyist), so please feel very free to correct me.

    I'm writing a tic-tac-toe game. I've got the game engine itself working, and I'm trying to wrap it up in a nice GUI.

    One aspect of the game is going to be a grid of buttons representing the board. When a button is clicked, I want a signal to be emitted witht he coordinates of the button.

    Here's what I've got:
    Qt Code:
    1. #ifndef UISPOT_HPP
    2. #define UISPOT_HPP
    3.  
    4. #include <QPushButton>
    5. #include <QIcon>
    6.  
    7. #include "spot.hpp"
    8.  
    9. namespace ttt {
    10. class UISpot : public QPushButton {
    11. Q_OBJECT
    12. private:
    13. Spot spot_;
    14. slots:
    15. void buttonClicked();
    16. signals:
    17. void clickedAt( const Coord &coord );
    18. public:
    19. UISpot( const Spot &spot, QWidget *parent ) :
    20. QPushButton( parent ),
    21. spot_( spot ) {
    22. connect( this, SIGNAL( clicked() ),
    23. this, SLOT( buttonClicked() ) );
    24. }
    25. };
    26. }
    27.  
    28. #endif // UISPOT_HPP
    To copy to clipboard, switch view to plain text mode 

    And uiSpot.cpp:

    Qt Code:
    1. #include "uiSpot.hpp"
    2.  
    3. namespace ttt {
    4. void UISpot::buttonClicked() {
    5. emit clickedAt( spot_.coord() );
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

    The Spot interface is irrelevent, so I didn't post it. Now, when I try to compile this, I get the following error messages:

    $ qmake -project
    $ qmake
    $ make
    ...
    <SNIP>
    ...
    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o uiSpot.o uiSpot.cpp
    uiSpot.hpp:15: error: expected primary-expression before ‘void’
    uiSpot.hpp:15: error: ISO C++ forbids declaration of ‘type name’ with no type
    uiSpot.hpp:15: error: expected ‘;’ before ‘void’
    uiSpot.cpp:4: error: no ‘void ttt::UISpot::buttonClicked()’ member function declared in class ‘ttt::UISpot’
    make: *** [uiSpot.o] Error 1
    At line 15 is where I declare the slots and signals. What am I doing wrong?

    Any help would be greatly appreciated.
    Last edited by jacek; 1st August 2007 at 14:53. Reason: changed [code] to [quote]

Similar Threads

  1. Signals and Slots question
    By Thoosle in forum Qt Programming
    Replies: 5
    Last Post: 5th December 2006, 00:24
  2. Nested signals and slots
    By vishva in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 09:47
  3. Signals and Slots in dll
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2006, 08:12
  4. Order of signals and slots
    By Morea in forum Newbie
    Replies: 1
    Last Post: 26th February 2006, 22:09
  5. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35

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.