我在我的程序中有这个函数将整数转换为字符串:
QString Stats_Manager::convertInt(int num)
{
stringstream ss;
ss << num;
return ss.str();
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行这个时,我得到错误:
aggregate 'std::stringstream ss' has incomplete type and cannot be defined
Run Code Online (Sandbox Code Playgroud)
我不确定这意味着什么.但如果您知道如何修复它或需要更多代码,请发表评论.谢谢.
我有一个打开另一个窗口的程序,我希望旧窗口关闭.是否有某些功能或某些内容会通过代码关闭窗口但是保持另一个窗口运行?
我一直收到这个错误:
cannot call member function 'QString Load::loadRoundsPlayed()'without object
Run Code Online (Sandbox Code Playgroud)
现在我对c ++和qt很新,所以我不确定这意味着什么.我试图从另一个类调用一个函数来设置一些lcdNumbers上的数字.这是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;
}
Run Code Online (Sandbox Code Playgroud)
这是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
Run Code Online (Sandbox Code Playgroud)
最后我调用函数的地方:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "load.h"
#include <QLCDNumber> …
Run Code Online (Sandbox Code Playgroud)