Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issues with QSettings::value()::toInt()
Forum Updated to NodeBB v4.3 + New Features

Issues with QSettings::value()::toInt()

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spode
    wrote on last edited by
    #1

    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);
    }
    @

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      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

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        spode
        wrote on last edited by
        #3

        That is right!

        is there no way to cript information of qsettings...or to hide them?

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          You did not answer my question.

          What do you expect as output from line 17 ?

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • S Offline
            S Offline
            spode
            wrote on last edited by
            #5

            Oh. Excuse me. Nothing, becouse i should have written QString::setNum(I).
            In fact it is right! :)

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved