我不断收到此错误:Qt的C++不能调用成员函数“”没有对象
cannot call member function 'QString Load::loadRoundsPlayed()'without object
现在即时通讯相当新的C++和Qt所以我不会知道这意味着什么。我正在尝试从另一个类中调用一个函数来设置一些lcdNumber上的数字。这里是Load.cpp持有功能:
#include "load.h"
#include <QtCore>
#include <QFile>
#include <QDebug>
Load::Load() //here and down
{}
QString Load::loadRoundsPlayed()
{
QFile roundsFile(":/StartupFiles/average_rounds.dat");
if(!roundsFile.open(QFile::ReadOnly | QFile::Text))
{
qDebug("Could not open average_rounds for reading");
}
Load::roundsPlayed = roundsFile.readAll();
roundsFile.close();
return Load::roundsPlayed;
}
这里是Load.h:
#ifndef LOAD_H
#define LOAD_H
#include <QtCore>
class Load
{
private:
QString roundsPlayed; //and here
public:
Load();
QString loadRoundsPlayed(); //and here
};
#endif // LOAD_H
最后的地方,我调用该函数:
当我运行这个我得到那个错误。林不知道这意味着什么,如果任何人都可以帮助我会感谢。谢谢。