Results 1 to 10 of 10

Thread: How to add QPushButton to QTreeWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to add QPushButton to QTreeWidget

    Hi wysota-san,

    Although very happy to hear back from you, I am now more confused than ever.

    Here is what I now think so far.

    I can make object of QTreeWidget and use QStandardItem. On QTreeWidgetItem object, I can call setIndexWidget to set a QPushButton where I wish. But that doesn't make sense since you initially discouraged saying that I should use QAbstractItemView::setIndexWIdget(), but I can have QAbstractItemView display since it's an Abstract Class.

    Please. SOS.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to add QPushButton to QTreeWidget

    setIndexWidget() is a method defined in QAbstractItemView but it is inherited by its subclasses (such as QTreeView or QTreeWidget) acording to rules of object oriented programming. And you shouldn't use setIndexWidget.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    shamas (23rd March 2012)

  4. #3
    Join Date
    Mar 2012
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to add QPushButton to QTreeWidget

    Hi,
    So as it turns out that to choose which of my columns in which rows needed to be click-able/editable, I could do that by setData(columnNumber, Qt.UserRole, "isDisabled") and using QtItemDelegate for QtreeWidget's setItemDelegate. Each time a certain box is double clicked, I can see if its data has userRole defined is "isDisabled" in which case it would return null.

    As far as the button was concerned, is set them as setData(columnNumber, Qt.UserRole, "shouldBehaveAsButton"), and when those are clicked, in QtItemDelegate, I would return null, and send command for button clicked. (Probably not a very user friendly idea, but will set colors or backgrounds in a way that it would look like a button and include this in my video demo)

    This solves my problem. Thanks you.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to add QPushButton to QTreeWidget

    Quote Originally Posted by shamas View Post
    So as it turns out that to choose which of my columns in which rows needed to be click-able/editable, I could do that by setData(columnNumber, Qt.UserRole, "isDisabled") and using QtItemDelegate for QtreeWidget's setItemDelegate. Each time a certain box is double clicked, I can see if its data has userRole defined is "isDisabled" in which case it would return null.
    There is an easier way. Each item in the model has a set of flags returned by QAbstractItemModel::flags(). Those flags include Qt::ItemIsEditable and Qt::ItemIsEnabled.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 0
    Last Post: 22nd February 2010, 09:30
  2. QPushButton
    By anafor2004 in forum Newbie
    Replies: 1
    Last Post: 21st October 2009, 16:31
  3. Replies: 2
    Last Post: 17th March 2008, 12:53
  4. Replies: 1
    Last Post: 19th October 2007, 01:29
  5. Replies: 3
    Last Post: 26th September 2006, 12:16

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.