我想创建一个简单的游戏,使用计时器,但我似乎无法得到它的工作。它会抛出这个错误:“没有匹配的函数调用'QObject :: connect(QTimer * &,const char *,Time * &,const char *)'”现在问题我做什么我无法修复它请帮助。当我遇到这个错误时,我才开始编写游戏。这里是排除不重要(目前)qml文件的文件。QTimer基本程序帮助
Main.cpp的:
#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include "time.h"
#include <QObject>
#include <QTimer>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
viewer.setMainQmlFile(QLatin1String("qml/RaakGame/main.qml"));
viewer.showExpanded();
Time *timmer = new Time;
QTimer *timer = new QTimer(0);
QObject::connect(timer, SIGNAL(timeout()), timmer, SLOT(ShowTime()));
timer->start(1000);
return app.exec();
}
time.h中:
#ifndef TIME_H
#define TIME_H
class Time
{
public:
Time();
private slots:
void ShowTime();
signals:
int setTime();
};
time.cpp:
#include "time.h"
int theTime = 60;
Time::Time()
{
ShowTime();
}
void Time::ShowTime()
{
theTime--;
}
int Time::setTime()
{
return theTime;
}
#endif // TIME_H