Hello every1!
I have this code:
class Model
{
public:
Model(const QString& path);
double getVehicleWeight()
{
m_settings->beginGroup("vehicle");
foreach
(const QString &childKey, childKeys
) {
//Here I want to return a double using QVariant, each line of my config file have (ex: weight = 60)
}
m_settings->endGroup();
}
private:
void initSettings(const QString& path);
protected:
std::unique_ptr<QSettings> m_settings;
};
Model::Model(const QString& path)
{
initSettings(path);
}
void Model::initSettings(const QString& path)
{
m_settings
= std
::make_unique<QSettings>
(path,
QSettings::IniFormat);
}
int main()
{
Model obj("/d/users/F27279C/Desktop/TESTINI/TestINI/New folder");
qDebug() << "PLS WORK!";
obj.getVehicleWeight();
}
class Model
{
public:
Model(const QString& path);
double getVehicleWeight()
{
m_settings->beginGroup("vehicle");
const QStringList childKeys = m_settings->childKeys();
foreach (const QString &childKey, childKeys)
{
//Here I want to return a double using QVariant, each line of my config file have (ex: weight = 60)
}
m_settings->endGroup();
}
private:
void initSettings(const QString& path);
protected:
std::unique_ptr<QSettings> m_settings;
};
Model::Model(const QString& path)
{
initSettings(path);
}
void Model::initSettings(const QString& path)
{
m_settings = std::make_unique<QSettings>(path, QSettings::IniFormat);
}
int main()
{
Model obj("/d/users/F27279C/Desktop/TESTINI/TestINI/New folder");
qDebug() << "PLS WORK!";
obj.getVehicleWeight();
}
To copy to clipboard, switch view to plain text mode
I know the ,,foreach" will go through all my document, but i dont want that
I want ot make a getter for every line of my config file which will return the value from it
All the values are double
so what I ask is:
- how can I access a specific line of my config for ex weight or speed?
- how can I return a double using QVariant?
thx for help!
Bookmarks