c++ - Read value of a text file and write the value into a QDoubleSpinBox -


i want read string (data) out of text file , write data qdoublespinbox. therefore used:

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;                                 {                     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)        {            ...        }    } 

when compiling no error message, when use method loaddirectory qstring "value" searched methods "qstring::indexof" , "qstring::mid" of file "/1_geo.m4" existence proofed qfileinfo::exists() not written qdoublespinbox "valueqdoublespinbox". can tell me why not working? greetings

imho following lines:

double valuenumber = value.todouble(); valuenumber = ui.valueqdoublespinbox->value(); // value spinbox 

have changed to:

double valuenumber = value.todouble(); ui.valueqdoublespinbox->setvalue(valuenumber); // set value of spinbox 

details: http://qt-project.org/doc/qt-4.8/qdoublespinbox.html#value-prop


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -