Results 1 to 3 of 3

Thread: implementing sizeHint in a QItemDelegate derivative

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default implementing sizeHint in a QItemDelegate derivative

    I am implementing an editable item model/view that uses delegates to provide custom editors. The editors are either QDoubleSpinBoxes or QComboBoxes. Now the size of the editor widget is very very small when displayed in the item view so I guess I have to reimplement the Delegates sizeHint. But how can I ask QStyle to tell me what the preffered size of a spinbox ?

    Thanks in advance

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: implementing sizeHint in a QItemDelegate derivative

    Will putting the following line in yourDelegate::createEditor() not do what you want?
    Qt Code:
    1. editor->setMinimumSize(editor->sizeHint());
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: implementing sizeHint in a QItemDelegate derivative

    When I use that in the createEditor function the editor widget is sort of shown outside of the cell as can be seen on the attached screenshot. This is however not the case when I use the sizeHint function.
    Attached Images Attached Images

Similar Threads

  1. correct sizeHint of QItemDelegate
    By nifei in forum Qt Programming
    Replies: 4
    Last Post: 17th November 2008, 09:50
  2. Replies: 4
    Last Post: 25th September 2008, 13:54
  3. sizeHint()
    By sm in forum Newbie
    Replies: 11
    Last Post: 22nd January 2008, 03:59
  4. sizeHint
    By eric in forum Newbie
    Replies: 1
    Last Post: 8th January 2008, 16:18
  5. How to set the sizehint for treeWidget
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 12th June 2007, 11:35

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.