Results 1 to 2 of 2

Thread: Buttons on item in QTreeView?

  1. #1
    Join Date
    Apr 2006
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Buttons on item in QTreeView?

    I'm trying to to put buttons on items in a QTreeView. I don't mean using buttons as an editor when clicked, but just have the button always there on some items to perform a quick action on the item.

    For example, something like the little "Eject" button that appears next to removable devices in the left-hand library tree in iTunes.

    I could make a delegate for the item and draw the button myself, but then I'd have to handle all the button press and hovers and everything.

    Any ideas?

    Thanks!
    Joel

  2. #2
    Join Date
    Apr 2006
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Buttons on item in QTreeView?

    Ok, well I figured it out eventually.

    Looks like there's at least three ways to do it, this thread suggests how to do it with delegates, and would work great if you had 1000s of items.

    But I'm only going to have a few hundred items at most, and so I really wanted to avoid that much complexity. It turns out there's a
    Qt Code:
    1. QAbstractItemView->setIndexWidget()
    To copy to clipboard, switch view to plain text mode 
    that will work, and I can just make a custom widget that has my label and my buttons.

    There's also QTreeWidget->setItemWidget() but I'm using QTreeView so I'm going with that.

Similar Threads

  1. QTreeView::item stylesheet
    By Baasie in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2009, 15:55
  2. QTreeView decorations as buttons
    By solarwar in forum Qt Programming
    Replies: 0
    Last Post: 23rd November 2008, 20:58
  3. QTreeView and item editing
    By roxton in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2008, 19:56
  4. Replies: 1
    Last Post: 4th July 2008, 18:17
  5. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 15:24

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.