QTableView comma as decimal separator
-
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. -
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.@nicmorais Verify your locale https://doc.qt.io/qt-5/qlocale.html
This is part of the much broader topic of application internationalisation.
-
@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()@nicmorais
What kind of editing widget do you get? Can you show a pic (before and) after entering the editing mode on a cell? -
-
@nicmorais
What kind of editing widget do you get? Can you show a pic (before and) after entering the editing mode on a cell?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.
-
@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);