Quoted
Object::connect: No such slot hero::move(UP)
Object::connect: No such slot hero::move(DOWN)
Object::connect: No such slot hero::move(RIGHT)
Object::connect: No such slot hero::move(LEFT)
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#ifndef GAMEFIELD_H
#define GAMEFIELD_H
#define TILE_SIZE 18
#define TILE_BORDER_SIZE 0 //Every tile's border right and bot
#include <QWidget>
#include <vector>
using namespace std;
class GameField : public QWidget
{
Q_OBJECT
int mapWidth;
int mapHeight;
int score;
void readMap(/*add parameter*/);
void saveMap(/*add parameter*/);
public:
GameField(QWidget * parent = 0);
~GameField();
int getMapWidth() const { return mapWidth; };
int getMapHeight() const { return mapHeight; };
void incScore(int i) { score+=i; };
protected:
void paintEvent(QPaintEvent *event);
vector< vector<char> > map;
};
#endif
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#ifndef HERO_H
#define HERO_H
#include "GameField.h"
enum direction { UP, DOWN, RIGHT, LEFT };
class hero : public GameField
{
Q_OBJECT
int lifeCount;
int xPos;
int yPos;
QRect model;
public:
hero(int,int,QPainter*);
QRect getModel() { return model; };
int findXPos();
int findYPos();
public slots:
void move(direction);
};
#endif
|
This post has been edited 3 times, last edit by "yyyeey" (Jan 31st 2012, 10:02pm)
This post has been edited 1 times, last edit by "Amleto" (Jan 31st 2012, 11:10pm)
|
|
Source code |
1 2 3 4 |
(void) new QShortcut(Qt::Key_Up, player, SLOT(move(UP))); (void) new QShortcut(Qt::Key_Down, player, SLOT(move(DOWN))); (void) new QShortcut(Qt::Key_Right, player, SLOT(move(RIGHT))); (void) new QShortcut(Qt::Key_Left, player, SLOT(move(LEFT))); |
Anyway, its sort of a different problem, so I guess the main one is solved. This post has been edited 1 times, last edit by "yyyeey" (Feb 1st 2012, 6:38am)
Quoted
GameField.cpp: In member function ‘virtual void GameField::paintEvent(QPaintEvent*)’:
GameField.cpp:81:57: error: no matching function for call to ‘QShortcut::QShortcut(Qt::Key, hero*&, const char [10])’
GameField.cpp:81:57: note: candidates are:
/usr/include/qt4/QtGui/qshortcut.h:68:5: note: QShortcut::QShortcut(const QKeySequence&, QWidget*, const char*, const char*, Qt:hortcutContext)
/usr/include/qt4/QtGui/qshortcut.h:68:5: note: no known conversion for argument 2 from ‘hero*’ to ‘QWidget*’
/usr/include/qt4/QtGui/qshortcut.h:67:14: note: QShortcut::QShortcut(QWidget*)
/usr/include/qt4/QtGui/qshortcut.h:67:14: note: candidate expects 1 argument, 3 provided
/usr/include/qt4/QtGui/qshortcut.h:57:20: note: QShortcut::QShortcut(const QShortcut&)
/usr/include/qt4/QtGui/qshortcut.h:57:20: note: candidate expects 1 argument, 3 provided
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#ifndef GAMEFIELD_H
#define GAMEFIELD_H
#define TILE_SIZE 18
#define TILE_BORDER_SIZE 0 //Every tile's border right and bot
#include <QWidget>
#include <vector>
#include "hero.h"
using namespace std;
class GameField : public QWidget
{
Q_OBJECT
int mapWidth;
int mapHeight;
int score;
hero *player;
void readMap(/*add parameter*/);
void saveMap(/*add parameter*/);
public:
GameField(QWidget * parent = 0);
~GameField();
int getMapWidth() const { return mapWidth; };
int getMapHeight() const { return mapHeight; };
void incScore(int i) { score+=i; };
protected:
void paintEvent(QPaintEvent *event);
vector< vector<char> > map;
};
#endif
|
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#ifndef HERO_H
#define HERO_H
#include <QWidget>
#include "GameField.h"
enum direction { UP, DOWN, RIGHT, LEFT };
class hero : public GameField
{
Q_OBJECT
int lifeCount;
int xPos;
int yPos;
QRect model;
public:
hero(int,int,QPainter*);
QRect getModel() { return model; };
int findXPos();
int findYPos();
public slots:
void moveUp();
void moveDown();
void moveRight();
void moveLeft();
};
#endif
|
|
|
Source code |
1 |
(void) new QShortcut(Qt::Key_Up, player, SLOT(moveUp())); |
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include ...
class hero; // NOT #include hero.
class GameField : public QWidget
{
Q_OBJECT
int mapWidth;
int mapHeight;
int score;
hero *player;
...
};
|