Results 1 to 3 of 3

Thread: QTreeView

  1. #1
    Join Date
    Mar 2006
    Posts
    53
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Smile QTreeView

    Hi all,

    How to add a column in QTreeView, and how to name that column ?

    Thanks,

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView

    The headers (i.e. columns) are a part of the model.

  3. The following user says thank you to e8johan for this useful post:

    npc (24th January 2007)

  4. #3
    Join Date
    Jan 2007
    Location
    Augsburg, Germany
    Posts
    75
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTreeView

    You need to use a model. Just look up QStandardItemModel in your documentation.

    Qt Code:
    1. QStandardItemModel* p = new QStandardItemModel(0, 2, myView);
    2. p->setHeaderData(0, Qt::Horizontal, "First Column");
    3. p->setHeaderData(1, Qt::Horizontal, "Second Column");
    4.  
    5. myView->setModel(p);
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to gri for this useful post:

    npc (24th January 2007)

Similar Threads

  1. QTreeView repaint
    By graeme in forum Qt Programming
    Replies: 17
    Last Post: 13th March 2012, 13:27
  2. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25
  3. Modify model data in QTreeView
    By YuriyRusinov in forum Qt Programming
    Replies: 6
    Last Post: 26th October 2006, 17:28
  4. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24
  5. 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.