Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]Can QTreeWidget Really be edited?
Forum Updated to NodeBB v4.3 + New Features

[Solved]Can QTreeWidget Really be edited?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 5.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    poppw
    wrote on last edited by
    #1

    Hi,everyone.

    I'm now puzzled about QTreeWidget.

    The doc says, QTreeWidget inherits from QAbstractItemView.I want the QTreeWidgetItem in a QTreeWidget to be editable when users double click the mouse on the item.

    I use
    @(QTreeWidget*)someTreeWidget->setEditTriggers(QAbstractItemView::DoubleClicked);@

    But When I run the program,double click seems of no use.The item is still read-only and can't be modified.

    Does anyone solve this problem before? Is the only way to use Model/View menthod & QTreeView instead?


    I'm sorry to trouble you.But I just found the key to the problem.

    It is about the QTreeWidgetItem.When you want to modify a item in QTreeWidget or others, set the edittriggers is not enough.

    Every item to be added in the widget must set theis flags first.

    @(QTreeWidgetItem*)someItem->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled);@

    And that may work.

    1 Reply Last reply
    1

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved