Results 1 to 5 of 5

Thread: QTableView icons

  1. #1
    Join Date
    Oct 2007
    Location
    Romania
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Question QTableView icons

    Is there a way in which I could display an icon to a row in QTableView? I want to put an icon like I put to the QTableWidgetItem. The icon to be in the same cell with the text. Is that possible?

    Thank you.

  2. #2
    Join Date
    Jul 2007
    Posts
    26
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QTableView icons


  3. #3
    Join Date
    Oct 2007
    Location
    Romania
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: QTableView icons

    I want to set items icons in QTableView not QtableWidget Do you know how I can do that?

  4. #4
    Join Date
    Jul 2007
    Posts
    26
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QTableView icons

    Sorry, missunderstood your sentence.

    I do it like so:
    Qt Code:
    1.  
    2. model->insertRow(itemCount, QModelIndex());
    3. pI = model->index(itemCount,0,QModelIndex());
    4. model->setData( pI, title, Qt::DisplayRole);
    5. model->item(itemCount, 0)->setEditable( false );
    6.  
    7. // Lot's of adding item+subitems code
    8.  
    9. pI = model->index(itemCount,0,QModelIndex());
    10. icon = setItemIcon(type, ownership);
    11. model->setData( pI, QIcon( icon ), Qt::DecorationRole );
    To copy to clipboard, switch view to plain text mode 

    setItemIcon() function is my own function in which I programaticaly choose which icon to use, and icon is a QString variable which contains strings like, ":/images/some_icon.xpm"
    And I use QStandardItemModel for the item model. But I think this works on all items.
    itemCount is the number to which row the icon should be assigned to and 0 is for the first column.

  5. #5
    Join Date
    Oct 2007
    Location
    Romania
    Posts
    13
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: QTableView icons

    Thanks a lot, this solved my problem You are great.

Similar Threads

  1. QIcon Icons are not visible
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2007, 19:11
  2. Suppressing menu icons on the Mac
    By Brandybuck in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2006, 19:00
  3. Facing problem with tool bar icons
    By jnana in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 08:37
  4. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49
  5. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 16:30

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.