Results 1 to 2 of 2

Thread: QTreeView questions about view doubles and more

  1. #1
    Join Date
    May 2007
    Location
    Huntsville, Alabama
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QTreeView questions about view doubles and more

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeView questions about view doubles and more

    Quote Originally Posted by davisjamesf View Post
    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.

  3. The following user says thank you to wysota for this useful post:

    davisjamesf (9th August 2007)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.