テキスト ファイルから文字列 (データ) を読み取り、そのデータを 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)
{
...
}
}
コンパイル時にエラーメッセージは表示されませんが、メソッド LoadDirectory を使用すると、存在を証明したファイル「/1_geo.m4」のメソッド「QString::indexOf」および「QString::mid」で検索された QString「Value」 with QFileInfo::exists() は QDoubleSpinBox "ValueQDoubleSpinBox" に書き込まれません。なぜ機能しないのか誰か教えてもらえますか?挨拶