Results 1 to 2 of 2

Thread: Qt4 set and read header data in tableView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 set and read header data in tableView

    It didn't work because view will take header data from model as you set model & implemented header data in model.

    try this: you need to do all the manipulations in model only

    Qt Code:
    1. QVariant CityModel::headerData(int section, Qt::Orientation orientation, int role) const
    2. {
    3. if (role == Qt::DisplayRole)
    4. {
    5.  
    6. if((0 == section ) && (orientation == Qt::Horizontal)
    7. return QVariant("Name");
    8. else
    9. return cities[section];
    10. }
    11. return QVariant();
    12. }
    To copy to clipboard, switch view to plain text mode 
    Thanks :-)

  2. The following user says thank you to prasad_N for this useful post:

    teele (22nd September 2015)

Similar Threads

  1. header for tableView of QStandardItemModel
    By Omid123 in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2015, 00:15
  2. tableview wordwrap header but not data columns
    By RolandHughes in forum Qt Programming
    Replies: 2
    Last Post: 28th October 2014, 01:05
  3. Change tableView vertical header
    By tinysoft in forum Newbie
    Replies: 1
    Last Post: 17th September 2011, 08:35
  4. TableView with header and footer for sums, avg and so on
    By extreme001 in forum Qt Programming
    Replies: 0
    Last Post: 18th April 2011, 20:56
  5. QT: editable tableview header issue.
    By raschko in forum Qt Programming
    Replies: 0
    Last Post: 27th February 2011, 19:15

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.