using .INI file[SOLVED]

Page  
3

August 25, 2011

Andre Andre
Area 51 Engineer
6031 posts

To solve the kind of questions of why a snippet of code like you show us does not work as you expect it, please learn to use a debugger. Set a breakpoint at the top of your function, and then step through your function one line at a time. It allows you to follow the programs flow through your function, thus giving you insight in why it doesn’t work the way you expect it.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

August 25, 2011

ogopa ogopa
Lab Rat
87 posts

mlong wrote:
I would suspect, then, that your original problem wasn’t in reading the values from the ini format, but rather where you were setting the values to the boards themselves. I don’t think you had shared that code.

Thnks for all your help so far. You are right, my problem was setting the values to the boards. sorry. I had shared all the code i had for the problem. What I did was I modified this code:

  1.  QSettings settings("/home/test/Documents/Wave/signalgenerator.ini", QSettings::IniFormat);
  2.     qDebug() << settings.allKeys();//qdebug
  3.  
  4.     settings.beginGroup("values");
  5.     const QStringList childKeys = settings.childKeys();
  6.     QHash<QString, QString> values;
  7.     foreach (const QString &childKey, childKeys) {
  8.  
  9.     qDebug() << childKey << "->" << settings.value(childKey).toString();//qdebug
  10.     values.insert(childKey, settings.value(childKey).toString());
  11.  
  12.        if (childKey.toInt() == 1) {
  13.  
  14.         calfactor = settings.value(childKey).toFloat();
  15.         ui->comboBox->setItemData(0, calfactor);
  16.  qDebug()<<"index:" << ui->comboBox->itemText(1)<<"    value:"<<ui->comboBox->itemData(1);//qdebug
  17.       }
  18.  
  19.     if (childKey.toInt() == 2) {
  20.  
  21.         calfactor = settings.value(childKey).toFloat();
  22.         ui->comboBox->setItemData(1, calfactor);
  23.         qDebug()<<"index:" << ui->comboBox->itemText(1)<<"    value:"<<ui->comboBox->itemData(1);//qdebug
  24.     }
  25. }
  26.     settings.endGroup();
  27.     qDebug() << "values hash:" << values;//qdebug

to get this one(which worked(but only if I put it under each onpushButton function) :

  1. QSettings settings("/home/test/Documents/Wave/signalgenerator.ini", QSettings::IniFormat);
  2.        settings.beginGroup("values");
  3.        const QStringList childKeys = settings.childKeys();
  4.        QHash<QString, QString> values;
  5.        foreach (const QString &childKey, childKeys) {
  6.            values.insert(childKey, settings.value(childKey).toString());
  7.            if (childKey.toInt() == ui->comboBox->currentIndex()+1) {calfactor = settings.value(childKey).toFloat();}
  8.        }
  9.        settings.endGroup();

Page  
3

  ‹‹ QVideo and AVI Formats      Multicolored text for tree/table/list items? ››

You must log in to post a reply. Not a member yet? Register here!