Блок кода с ошибкой:
void QtLauncher::saveConfig()
{
QFile config(QCoreApplication::applicationDirPath() + "/config.cfg");
config.open(QIODevice::ReadOnly);
QByteArray buffer = config.readAll();
config.close();
config.open(QIODevice::ReadWrite | QIODevice::Truncate);
int index;
if((index = buffer.indexOf(QString("game_id="))) != -1)
{
char str[32];
sprintf_s(str, sizeof(str), "game_id=%i", game_id);
buffer.replace(index, buffer.indexOf("\n", index), str);
}
if((index = buffer.indexOf(QString("username="))) != -1)
{
char str[256];
sprintf_s(str, sizeof(str), "username=%s,%s,%s,%s", game_username[0].toStdString().c_str(), game_username[1].toStdString().c_str(), game_username[2].toStdString().c_str(), game_username[3].toStdString().c_str());
buffer.replace(index, buffer.indexOf("\n", index) - index, str);
}
if((index = buffer.indexOf(QString("game_path="))) != -1)
{
char str[256];
sprintf_s(str, sizeof(str), "game_path=%s,%s,%s,%s", game_path[0].toStdString().c_str(), game_path[1].toStdString().c_str(), game_path[2].toStdString().c_str(), game_path[3].toStdString().c_str());
buffer.replace(index, buffer.size() - index, str);
}
config.write(buffer);
config.close();
}
Ошибка:
D:\mp-launcher\launcher.cpp:288: ошибка: no matching function for call to 'QByteArray::indexOf(QString)'
launcher.cpp: In member function 'void QtLauncher::saveConfig()':
launcher.cpp:288:31: error: no matching function for call to 'QByteArray::indexOf(QString)'
288 | if((index = buffer.indexOf(QString("game_id="))) != -1)
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
Работаю на QT Creator 6.0.1, qt 6.2.3 установлена, mingw, компилятор qmake.