Ich hoffe die Informationen reichen
Code: Alles auswählen
void MindRacer::changeStrecke()
{
QFile file(fileName);
if(!file.open(QIODevice::ReadOnly))
{
QMessageBox::information(this, "Datei konnte nicht geöffnet werden", file.errorString());
return;
}
for(int x=0;x != (ui.streckenBox->currentIndex()+1);x++)
{
if(x == ui.streckenBox->currentIndex())
{
bool ok;
QString line = file.readLine();
file.close();
QStringList data = line.split(";");
str.x1 = data[1].toInt(&ok, 10);
if (ok == false)
return;
str.x2 = data[2].toInt(&ok, 10);
if (ok == false)
return;
str.y1 = data[3].toInt(&ok, 10);
if (ok == false)
return;
str.y2 = data[4].toInt(&ok, 10);
if (ok == false)
return;
data.clear();
line.clear();
}
}
int xdif = (str.x2 - str.x1);
int ydif = (str.y2 - str.y1);
//////////////////////////////////////////////////////////////////////////
ui.labelxd->setText(QString::number(xdif, 10));
ui.labelyd->setText(QString::number(ydif, 10));
//////////////////////////////////////////////////////////////////////////
ui.streckenLabel->setText(ui.streckenBox->currentText());
}