Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDoubleSpinBox and QLocale



  • Hello everybody!

    I am trying to use a set a QLocale in a QDoubleSpinBox, but its not working. The data input does not change at all.

    What am I missing?

    Thanks a lot.

    @
    QDoubleSpinBox *doubleSpinBoxEditor = new QDoubleSpinBox(parent);
    doubleSpinBoxEditor->setDecimals(4);
    doubleSpinBoxEditor->setAlignment(Qt::AlignRight);
    doubleSpinBoxEditor->setPrefix("$ ");

    doubleSpinBoxEditor->setLocale(QLocale(QLocale::Portuguese, QLocale::Brazil));
    return doubleSpinBoxEditor;
    

    @



  • Hi,
    Your code looks valid. Maybe set a value in it to make sure that a 'redraw' has taken place. Do you also install a translator?

    It's just a coding standard thing, but it's not so great to return a pointer to a stack constructed variable.



  • I did set the value and it stills not working. Any other ideas?

    @
    QDoubleSpinBox *doubleSpinBoxEditor = new QDoubleSpinBox(parent);
    doubleSpinBoxEditor->setRange(0.0000, 999999999999999.9999);
    doubleSpinBoxEditor->setDecimals(4);
    doubleSpinBoxEditor->setAlignment(Qt::AlignRight);
    doubleSpinBoxEditor->setPrefix("$ ");
    doubleSpinBoxEditor->setLocale(QLocale(QLocale::Portuguese, QLocale::Brazil));
    doubleSpinBoxEditor->setValue(0.0000);

    return doubleSpinBoxEditor;
    

    @


Log in to reply