PDA

View Full Version : Howto validate input in QStandardItem



andsun
13th May 2015, 08:10
Hi guys,

I'm feeling as a newby (am one mayby ;) )
I'm in code project and got a problem I can't solve in a simple way or can't see the solution.

Have a Table that I populate with QStandardItem's into a QStandardItemModel and filter through a QSortFilterProxyModel with 3 columns.
All data can be changed, the first column with any text and the rest should be validated numeric US formatted double ('.' separator) and max 8 digits.

Have looked and tried but not found any way to validate like the QValidators example gives the validation.

Any ideas how to set the validation to the two double column items?
Can I use QDoubleValidator in any way?



/anders

ChrisW67
13th May 2015, 09:37
Provide your table view with a custom QStyledItemDelegate for the columns concerned and provide either a suitable QDoubleSpinbox, or a QLineEdit with an attached validator in the createEditor() function.

andsun
13th May 2015, 10:08
Hi and thks,

shall give them a try.
Testing spinbox at the moment, though at doesn't show in the cell when doubleclick

Shall change to DoubleSpinbox and try...

/a

andsun
13th May 2015, 12:57
Thank's ChrisW67

It worked with subclassing into DoubleSpinBoxDelegate, as spinbox example for col 1 -2.

/a