Results 1 to 14 of 14

Thread: QTableView with a column of images

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Location
    Paris
    Posts
    9
    Qt products
    Platforms
    Windows

    Default QTableView with a column of images

    I have a QTableView to display some informations of a database in the form of a grid. One of the fields is a path to an image and I would like to display these images in my table.

    I tried something with a delegate, but I'm not really confortable with them and I couldn't get anything working. I also tried something with the role :
    Qt Code:
    1. if index.column() == 4:
    2. if role == QtCore.Qt.DecorationRole:
    3. label = QtGui.QLabel()
    4. path = "path/to/my/picture.jpg"
    5. image = QtGui.QImage(str(path))
    6. pixmap = QtGui.QPixmap.fromImage(image)
    7. label.setPixmap(pixmap)
    8. return label
    To copy to clipboard, switch view to plain text mode 

    This piece of code is inspired by something I found in another forum and that was supposed to work. However it doesn't do anything for me, only slows down the execution of my code.

    Any idea why it's not working ? If you have an example with a delegate I'd appreciate it also!

    Thanks for your attention
    Last edited by elanari; 24th June 2011 at 10:43.

Similar Threads

  1. how to disbale a column in a QTableView
    By rdjenner in forum Qt Programming
    Replies: 8
    Last Post: 14th August 2019, 15:44
  2. QTableView set column Decimals
    By ottoshmidt in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2010, 05:00
  3. Currently sorted column in QTableView
    By borges in forum Newbie
    Replies: 1
    Last Post: 21st September 2007, 16:52
  4. Fixating column from QTableView ?
    By pinktroll in forum Qt Programming
    Replies: 2
    Last Post: 4th September 2007, 10:53
  5. QTableView without the first counter column?
    By pmaktieh.sirhc in forum Qt Programming
    Replies: 2
    Last Post: 4th January 2007, 22:03

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.