Issues with QSettings::value()::toInt()
-
Why can not i obtain data i need from this class, though it does not return errors and is similar than the snippet provided by QSettings (editor)?
@
#include "programsettings.h"#include <QSettings>
#include <QVariant>
#include <QDesktopWidget>
#include <messaggioantipanico.h>
#include <QDebug>ProgramSettings::ProgramSettings()
{
}int ProgramSettings::getIngrandimento()
{
QSettings s("SeiFreud", "Tecnophobie");
int i = s.value("ingrandimento", QVariant::fromValue(1)).toInt();
qDebug()<< "ingrandimento corrente: " + i;
return i;
}void ProgramSettings::setIngrandimento(const int nvalue)
{
qDebug()<<"ingrandimento incrementato di uno: " + nvalue;
if(nvalue > 0 && nvalue < 4)
{
QSettings s("SeiFreud", "Tecnophobie");
s.setValue("ingrandimento", QVariant::fromValue(nvalue));emit ingrandimentoChanged(nvalue); qDebug()<<"signal"; } else { MessaggioAntiPanico a("Non è possibile cambiare ulteriormente l' ingrandimento!"); a.show(); }
}
QRect ProgramSettings::getDesktopDims()
{
QDesktopWidget * d = new QDesktopWidget();
return d->screenGeometry(-1);
}QSize ProgramSettings::getDesktopDimsAsQSize()
{
QDesktopWidget * d = new QDesktopWidget();
return QSize(d->width(), d->height());
}int ProgramSettings::getDesktopHeight()
{
return ProgramSettings::getDesktopDims().width();
}int ProgramSettings::getDesktopWidth()
{
return ProgramSettings::getDesktopDims().height();
}void ProgramSettings::addIngrandimento()
{
qDebug()<<"addIngrandimento";
qDebug()<<"ingrandimento non aggiornato: " + this->getIngrandimento();
this->setIngrandimento(this->getIngrandimento() + 1);
}void ProgramSettings::reduceIngrandimento()
{
this->setIngrandimento(this->getIngrandimento() - 1);
}
@ -
Can you explain why you are adding the integers to a string as you do in a number of your qDebug() output?
E.g.
line 17
line 23
line 64 -
That is right!
is there no way to cript information of qsettings...or to hide them?
-
You did not answer my question.
What do you expect as output from line 17 ?
-
Oh. Excuse me. Nothing, becouse i should have written QString::setNum(I).
In fact it is right! :)