我不斷收到此錯誤: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
最後的地方,我調用該函數:
當我運行這個我得到那個錯誤。林不知道這意味着什麼,如果任何人都可以幫助我會感謝。謝謝。