QTableWidget and Decimal places
Code:
//Getting the two QTableWidgetItem below
//Copying the value of ietm1 to item2
item2->setText(item1->text());
If the value of item 1 is "100.10" then it is copied as "100.1", how to make it copy as it is - "100.10"
Also is it possible to filter the input to the qtablewidget. I want only decimal input to be accpeted.
Thanks !
Re: QTableWidget and Decimal places
I have the same problem and I wrote the following workaround:
Code:
QVariant value
= item1
->data
(Qt
::DisplayRole);
// This is trick, because QItemDelegatePrivate::valueToText incorrect convert numbers with floating point
item2->setData(Qt::DisplayRole, value.toString());
Re: QTableWidget and Decimal places
thanks !
a few questions though
Q1. Is the text() same as Data(Qt::DisplayRole) ?
Re: QTableWidget and Decimal places
yup
Code:
{ setData(Qt::DisplayRole, atext); }