Hello,
I creating small app for my university and I stucked at one problem - no such slot.
Maybe now I put some code and explain it later.
Game. h
Q_OBJECT
public slots:
void displayMainMenu();
void showHelp(Button &start,Button &score,Button &help,Button &quit);
};
class Game: public QGraphicsView{
Q_OBJECT
public slots:
void displayMainMenu();
void showHelp(Button &start,Button &score,Button &help,Button &quit);
};
To copy to clipboard, switch view to plain text mode
Game.cpp
void Game::displayMainMenu() {
Button
* playButton
= new Button
(QString("../Sources/Pictures/Menu/start-inactive.png"),
QString("../Sources/Pictures/Menu/start-active.png"));
connect(playButton,SIGNAL(clicked()), this, SLOT(start()));
Button
* scoresButton
= new Button
(QString("../Sources/Pictures/Menu/scores-inactive.png"),
QString("../Sources/Pictures/Menu/scores-active.png"));
connect(scoresButton,SIGNAL(clicked()), this, SLOT(showScores()));
Button
* helpButton
= new Button
(QString("../Sources/Pictures/Menu/help-inactive.png"),
QString("../Sources/Pictures/Menu/help-active.png"));
connect(helpButton,SIGNAL(clicked()), this, SLOT(showHelp(playButton, scoresButton, helpButton, quitButton)));
Button
* quitButton
= new Button
(QString("../Sources/Pictures/Menu/quit-inactive.png"),
QString("../Sources/Pictures/Menu/quit-active.png"));
connect(quitButton,SIGNAL(clicked()), this, SLOT(close()));
}
void Game::displayMainMenu() {
Button* playButton = new Button(QString("../Sources/Pictures/Menu/start-inactive.png"),
QString("../Sources/Pictures/Menu/start-active.png"));
connect(playButton,SIGNAL(clicked()), this, SLOT(start()));
Button* scoresButton = new Button(QString("../Sources/Pictures/Menu/scores-inactive.png"),
QString("../Sources/Pictures/Menu/scores-active.png"));
connect(scoresButton,SIGNAL(clicked()), this, SLOT(showScores()));
Button* helpButton = new Button(QString("../Sources/Pictures/Menu/help-inactive.png"),
QString("../Sources/Pictures/Menu/help-active.png"));
connect(helpButton,SIGNAL(clicked()), this, SLOT(showHelp(playButton, scoresButton, helpButton, quitButton)));
Button* quitButton = new Button(QString("../Sources/Pictures/Menu/quit-inactive.png"),
QString("../Sources/Pictures/Menu/quit-active.png"));
connect(quitButton,SIGNAL(clicked()), this, SLOT(close()));
}
To copy to clipboard, switch view to plain text mode
void Game::showHelp(Button &play, Button &scores, Button &help, Button &quit) {
/* some stuff here with these buttons */
}
void Game::showHelp(Button &play, Button &scores, Button &help, Button &quit) {
/* some stuff here with these buttons */
}
To copy to clipboard, switch view to plain text mode
Above I show my code and now I will explain you what I want to do, so I want send these buttons in parameters and use them by my idea, but when I compile my program I getting this error message:
QObject::connect: No such slot Game::showHelp(playButton, scoresButton, helpButton, quitButton)
Button class is made by myself and with it class isn't any problem I guess.
I have tried all things which I found on the internet.
Of course I clean/rebuild my project before. I had Q_OBJECT macro in game.h too.
PS. I delete some unnecessary code but if you want I can update this any time
Any help would be appreciated
Bookmarks