Results 1 to 3 of 3

Thread: tableview wordwrap header but not data columns

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2008
    Posts
    183
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default tableview wordwrap header but not data columns

    I haven't went down the path of trying this yet. The documentation isn't clear so I thought I would ask before burning too much time on it. When deriving from the QAbstractTableView, is it possible to have wordwrap enabled for column headers but not data. The documentation for wordwrap just says "items" without indicating if they are header items or data items. Has anyone ever turned wordwrap on for the horizontal header but off for all data cells?

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

    Default Re: tableview wordwrap header but not data columns

    Eeem... There is no QAbstractTableView class, did you mean QAbstractTableModel or QTableView?

    BTW. The header in the view is a separate widget, there are no "header items". The data for the headers is taken from implementation of QAbstractItemModel::headerData(). The layout of the header is implemented by QHeaderView. To override its look, reimplement paintSection().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2014
    Posts
    30
    Thanks
    4
    Qt products
    Qt5

    Default Re: tableview wordwrap header but not data columns

    I am struggling with the same issue. QHeaderView does not support word wrapping nor multiple lines. It's been quite frustrating and time consuming to deal with these limitations.

    As a solution I tried feeding the header strings into a word wrap function that turns a longer string into multiple lines separated by a '\n' character. When I provide the multi-line string to the QHeaderView inside headerData(), it mostly works except for the following bug:

    Capture.PNG

    Single line headers are all grey whereas this header has the white gap at the top. How would I go about fixing this color issue? If I can fix this issue then I'd say we have a working solution. I'd be happy to post the word wrap algorithm if it will help anybody.
    Last edited by jmalicke; 28th October 2014 at 01:12.

Similar Threads

  1. Replies: 3
    Last Post: 5th January 2011, 22:55
  2. Replies: 3
    Last Post: 6th October 2010, 08:33
  3. Replies: 1
    Last Post: 12th October 2009, 09:33
  4. wordwrap for QTreeWidget columns
    By addu in forum Qt Programming
    Replies: 0
    Last Post: 31st July 2009, 17:42
  5. Set the same header to two columns
    By ProTonS in forum Qt Programming
    Replies: 1
    Last Post: 21st July 2009, 08:10

Tags for this Thread

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.