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. QTableView comma as decimal separator
Forum Updated to NodeBB v4.3 + New Features

QTableView comma as decimal separator

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 949 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.
  • nicmoraisN Offline
    nicmoraisN Offline
    nicmorais
    wrote on last edited by
    #1

    Hello everyone.
    I have a QTableView with a QStandardItemModel as model, some of the data are float values, and when I double-click on those cells in order to edit them, the decimal separator becomes a dot, and it does not accept comma as decimal separator.
    I want it to accept the comma, how can I do so? Thanks.

    artwawA 1 Reply Last reply
    0
    • nicmoraisN nicmorais

      Hello everyone.
      I have a QTableView with a QStandardItemModel as model, some of the data are float values, and when I double-click on those cells in order to edit them, the decimal separator becomes a dot, and it does not accept comma as decimal separator.
      I want it to accept the comma, how can I do so? Thanks.

      artwawA Offline
      artwawA Offline
      artwaw
      wrote on last edited by
      #2

      @nicmorais Verify your locale https://doc.qt.io/qt-5/qlocale.html

      This is part of the much broader topic of application internationalisation.

      For more information please re-read.

      Kind Regards,
      Artur

      1 Reply Last reply
      0
      • nicmoraisN Offline
        nicmoraisN Offline
        nicmorais
        wrote on last edited by nicmorais
        #3

        @artwaw
        Hello
        Yes, the locale is set, I can see it on the application output with qDebug(). But nothing changes! I also tried setting the locale with QTableView::setLocale()

        JonBJ 1 Reply Last reply
        0
        • nicmoraisN nicmorais

          @artwaw
          Hello
          Yes, the locale is set, I can see it on the application output with qDebug(). But nothing changes! I also tried setting the locale with QTableView::setLocale()

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @nicmorais
          What kind of editing widget do you get? Can you show a pic (before and) after entering the editing mode on a cell?

          nicmoraisN 1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            See https://bugreports.qt.io/browse/QTBUG-78094

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            nicmoraisN 1 Reply Last reply
            0
            • JonBJ JonB

              @nicmorais
              What kind of editing widget do you get? Can you show a pic (before and) after entering the editing mode on a cell?

              nicmoraisN Offline
              nicmoraisN Offline
              nicmorais
              wrote on last edited by nicmorais
              #6

              @JonB Captura de tela_2021-11-20_13-41-55.png Captura de tela_2021-11-20_13-42-58.png

              So, I also created a new project and everything was working fine! Now I need to find some way to fix it in my other project. In these screenshots, the value of column 5 is the value of the column 3 multiplied by the value of the column 4.

              I get an inline editing whenever I enter editing mode, the value was a long one, like 6.85499987.

              1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                See https://bugreports.qt.io/browse/QTBUG-78094

                nicmoraisN Offline
                nicmoraisN Offline
                nicmorais
                wrote on last edited by
                #7

                @Christian-Ehrlicher Thanks a lot, I don't know why, but in a new project I've just created everything was working fine...

                    QStandardItem *item = new QStandardItem;
                    item->setData(5.56, Qt::EditRole);
                    itemModel->setItem(0, 0, item);
                    ui->tableView->setModel(itemModel);
                
                1 Reply Last reply
                0
                • nicmoraisN Offline
                  nicmoraisN Offline
                  nicmorais
                  wrote on last edited by nicmorais
                  #8

                  Solved by setting the values as doubles insted of floats. Thanks a lot for your attention, guys.

                  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