Results 1 to 3 of 3

Thread: Tree View with Icons/primitives

  1. #1
    Join Date
    Sep 2008
    Posts
    21
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Tree View with Icons/primitives

    Hello,


    I am reading a database and would like to view the some of the contents of the database in tree view with items represented as icons/primitives(colored circles,rectangles) along with the text.

    Could anyone provide some reference on that issue?


    Thanks
    Sajjad

  2. #2
    Join Date
    Sep 2008
    Posts
    25
    Thanks
    3
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Tree View with Icons/primitives

    Hi
    Use QTreeView for displaying you data
    QStandardItemModel for creating a tree
    QStandardItem as an item in your tree, QStandardItem has a setIcon() method

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

    dosto.walla (3rd October 2008)

  4. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Tree View with Icons/primitives

    do you mean how to set an icon in QTreeView or QTreeWidget?
    for QTreeView use this method
    bool QAbstractItemModel::setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole )
    example
    Qt Code:
    1. ...
    2. model()->setData(index, QIcon(fileName), Qt::DecorationRole);
    3. ...
    To copy to clipboard, switch view to plain text mode 
    for QTreeWidget
    Qt Code:
    1. ...
    2. item->setIcon(column, QIcon(fileName));
    3. ...
    To copy to clipboard, switch view to plain text mode 

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

    dosto.walla (3rd October 2008)

Similar Threads

  1. Vertical alignment of rows in a tree view
    By Micawber in forum Qt Programming
    Replies: 9
    Last Post: 17th June 2008, 21:06
  2. Replies: 2
    Last Post: 18th March 2008, 15:38
  3. Ignore mouse events out of tree view
    By krishna.bv in forum Qt Programming
    Replies: 3
    Last Post: 27th December 2006, 11:24
  4. Model, View and Proxy
    By No-Nonsense in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2006, 08:50
  5. tree view!!
    By Seema Rao in forum Qt Programming
    Replies: 4
    Last Post: 9th May 2006, 14:09

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.