0
テキストファイルから文字列(データ)を読み取り、そのデータをQDoubleSpinBoxに書きたいとします。したがって、私が使用:テキストファイルの値を読み取り、その値をQDoubleSpinBoxに書き込む
void GUIsubclassKuehniGUI::LoadDirectory()
{
QString loadedDirectory = QFileDialog::getExistingDirectory(this,
"/home",tr("Create Directory"),
QFileDialog::DontResolveSymlinks);
ui.PathDirectory -> setText(loadedDirectory);
QFileInfo GeoDat1 = loadedDirectory + "/1_geo.m4";
QFileInfo GeoDat2 = loadedDirectory + "/2_geo.m4";
QString Value;
if (GeoDat1.exists() == true)
{
QFile GEO (loadedDirectory + "/1_geo.m4");
if(GEO.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream Stream (&GEO);
QString Text;
do
{
Text = Stream.readLine();
QString startWith = "start";
QString endWith = "stop" ;
int start = Text.indexOf(startWith, 0, Qt::CaseInsensitive);
int end = Text.indexOf(endWith, Qt::CaseInsensitive);
if (start != -1)
Value = Text.mid(start + startWith.length(), end - (start + startWith.length()));
qDebug() << Value << (start + startWith.length()) << (end - (start + startWith.length()));
double ValueNumber = Value.toDouble();
ValueNumber = ui.ValueQDoubleSpinBox->value();
}
while(!Text.isNull());
GEO.close();
}
}
else if (GeoDat2.exists() == true)
{
...
}
}
をコンパイルする場合、私は何のエラーメッセージが出ていないが、私はQStringの「バリュー」はメソッド「QStringの::のindexOf」との「QStringの::半ば」で検索LoadDirectoryメソッドを使用する場合QFileInfo :: exists()でプルーフされたファイル "/1_geo.m4"はQDoubleSpinBox "ValueQDoubleSpinBox"に書き込まれません。誰かがそれがなぜ機能していないのか教えてもらえますか?挨拶は
うんあなたは正しいです - それは今正常に動作します。 :D – Streight