Results 1 to 2 of 2

Thread: Rename a QTreeView->header() column??

  1. #1
    Join Date
    Aug 2008
    Posts
    39
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Rename a QTreeView->header() column??

    I am trying to rename a QTreeView->header()-> setColumnText(0, "Rename");

    This QTreeView has been initalized like this:
    Qt Code:
    1. QTreeView *treeView = new QTreeView();
    2. QDirModel *dirModel = new QDirModel();
    3.  
    4. dirProxyModel->setSourceModel(dirModel);
    5. treeView->setModel(treeProxyModel);
    6.  
    7. // I'd like to rename the column header for this, how?
    8. treeView->header()->setColumnText(0, "Folders");
    To copy to clipboard, switch view to plain text mode 

    There doesn't seem to be a clear way to do this?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Rename a QTreeView->header() column??

    treeView->header()->setColumnText(0, "Folders");
    I didnt find setColumnText to be a member function of QHeaderView !! I wonder if ur code compiles ...

    Anyways, you can try QAbstractItemModel::setHeaderData.
    Somethins like -
    Qt Code:
    1. dirModel->setHeaderData(0,Qt::Horizontal,"Folders");
    To copy to clipboard, switch view to plain text mode 

    Hope this works

Similar Threads

  1. QTreeView Fixed column & QTableView
    By jpujolf in forum Qt Programming
    Replies: 4
    Last Post: 13th August 2008, 09:35
  2. Fixed Column in QTreeview
    By ormonde in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2008, 07:49
  3. No delegate for 1 column in QTreeView
    By mace in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2007, 10:55
  4. How to dispay an icon in the first column of QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 1
    Last Post: 5th January 2006, 15:51

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.