PDA

View Full Version : QTreeView questions about view doubles and more



davisjamesf
8th August 2007, 22:23
couple of questions:
I have created a QStandardItemModel to hold my data and QTreeView to view it. The data in the QStandardItemModel contain text, integers, and doubles.

1) My doubles are showing up in the a scientific notation like 1.1234e+09. How do I get it to show up in a form like 12345678911.1234 in the TreeView?

I was able to make a delegate to open a double spin box to see the whole number but not sure how to make it show up in the view. I thought the delegate was supposed to also help me make the data show up in the tree like I want, but I am not sure how to do this.

2) I was able to set the doublespinbox delegate for individual columns, but not all the data in the columns are doubles (some data are qstrings and others are ints). How do I set different delegates for individual cells or items?...should I use one delegate and somehow tell it how to enter data?

Thanks,
James

wysota
9th August 2007, 00:39
I was able to make a delegate to open a double spin box to see the whole number but not sure how to make it show up in the view. I thought the delegate was supposed to also help me make the data show up in the tree like I want, but I am not sure how to do this.
You can reimplement QAbstractItemDelegate::paint() and do the painting yourself.


2) I was able to set the doublespinbox delegate for individual columns, but not all the data in the columns are doubles (some data are qstrings and others are ints). How do I set different delegates for individual cells or items?...should I use one delegate and somehow tell it how to enter data?

Use a smart delegate that will check the contents type (for example by checking QVariant::type() for data returned by the data() method of the model) and act accordingly.