Results 1 to 8 of 8

Thread: Custom Item Delegate (QDateEdit) and Size Hints

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Custom Item Delegate (QDateEdit) and Size Hints

    G'day,

    After a discussion in another thread I am experimenting with a custom delegate (QStyledItemDelegate) to handle "date" fields coming from an Sqlite database. I've built the delegate and, for the most part, got it working. I have called QTableView::resizeColumnsToContents() and set QHeaderView::setResizeMode(QHeaderView::ResizeToContents) so the display mode has the date column resized to fit.

    The problem comes when I go into edit mode. The text string ISO data coming from Sqlite is converted to QDate and passed to the QDateEdit control the delegate has set up to edit it. The editor is rendered in the QTableView cell but the spin box controls invariably overlay the right end of the date.

    I am struggling to find how I can have the column resize to fit the QDateEdit spin box controls and still have the date displayed without truncation. I'm guessing that some magic is required in the delegate's size hint but cannot see how I can determine a good hint. There must be some way to get at the size of the edit control (no pointer to this is passed to sizeHint()) to add to the string size but I'm not familiar enough with the style options stuff to locate it.

    Any nudges in the right direction would be greatly appreciated.
    Chris W

    QT4.5.1
    Last edited by ChrisW67; 27th May 2009 at 09:14. Reason: Better title

Similar Threads

  1. Replies: 5
    Last Post: 10th August 2009, 10:50
  2. Delegate for a certain item?
    By somebody in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2008, 22:55
  3. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37
  4. QMovie from inside a custom item delegate
    By Crazy_Hopper in forum Qt Programming
    Replies: 3
    Last Post: 7th May 2008, 15:18
  5. list of custom item views?
    By Beluvius in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2008, 06:43

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
  •  
Qt is a trademark of The Qt Company.