Results 1 to 4 of 4

Thread: Treeview with buttons

  1. #1
    Join Date
    Jul 2009
    Location
    Amsterdam
    Posts
    2
    Qt products
    Platforms
    Windows

    Default Treeview with buttons

    I'm looking for a way to get buttons (or other controls) in one of the columns of the treeView.
    Currently i'm using a QtreeView and have the QStandardItemModel in use.
    I'm able to get a string in the columns, but need a button to be there.

    My code is written in python, but it should be fairly easy to read for non python users.

    I did look around on google to get this solved, that helped a little bit, but it's a bit to complicated to solve on my own.
    Is there anyone that knows how to do this?

    The code down here is the procedure that fils the currently created treeView:

    Qt Code:
    1. def addToList2(self):
    2. model = QtGui.QStandardItemModel(self.treeView)
    3. self.treeView.setModel(model)
    4.  
    5. model.insertRows(0, 4)
    6. model.insertColumns(0, 4)
    7.  
    8. row = col = 0
    9. while row < 4:
    10. col = 1
    11. while col < 4:
    12. index = model.index(row, col)
    13. model.setData(index, QtCore.QVariant('X'))
    14. col += 1
    15. row += 1
    16.  
    17. self.treeView.show()
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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: Treeview with buttons

    I don't understand, do you need buttons in a header of a treeView or buttons as items of a treeView?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jul 2009
    Location
    Amsterdam
    Posts
    2
    Qt products
    Platforms
    Windows

    Default Re: Treeview with buttons

    This is what i'm trying to build:



    The red/green/yellow and blue squares would represent buttons that perform a task on the file it shares a row with.

  4. #4
    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: Treeview with buttons

    I see, then take a look at QItemDelegate.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Radio buttons in a tree view
    By notwithstanding in forum Qt Programming
    Replies: 6
    Last Post: 3rd November 2008, 22:32
  2. tool buttons on top of label
    By McKee in forum Qt Programming
    Replies: 5
    Last Post: 2nd November 2008, 16:07
  3. qt3 to qt4 conversion: no toolbar buttons
    By hugo vanwoerkom in forum Qt Programming
    Replies: 9
    Last Post: 25th October 2007, 17:07
  4. Problem with Parent QWidget and Buttons not working
    By VireX in forum Qt Programming
    Replies: 7
    Last Post: 11th May 2007, 22:24
  5. array of radio buttons
    By amulya in forum Qt Programming
    Replies: 4
    Last Post: 5th October 2006, 12:59

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
  •  
Qt is a trademark of The Qt Company.