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. QTreeWidget editItem()
Forum Update on Monday, May 27th 2025

QTreeWidget editItem()

Scheduled Pinned Locked Moved Unsolved General and Desktop
editableqtreewidget
5 Posts 2 Posters 3.0k Views
  • 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.
  • L Offline
    L Offline
    Lorence
    wrote on last edited by
    #1

    void MyTreeWidget::createChild()
    {
    QTreeWidgetItem* new_child = new QTreeWidgetItem();
    new_child->setText(0,"Untitled Playlist");
    new_child->setFlags(new_child->flags() | Qt::ItemIsEditable);
    topLevelItem(1)->insertChild(0,new_child);
    editItem(new_child);
    }
    after this function executes, the new_child should be edited now
    but when i use qDebug() to it, it outputs "Untitled Playlist"

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Lorence
      wrote on last edited by Lorence
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Where are you calling that qDebug ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        L 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Where are you calling that qDebug ?

          L Offline
          L Offline
          Lorence
          wrote on last edited by Lorence
          #4

          @SGaist
          hello,
          here

          void MyTreeWidget::keyPressEvent(QKeyEvent *e)
          {
          if ( ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) && !hasFocus() )
          {

              qDebug() << topLevelItem(1)->child(0)->text(0);
              emit newChildCreated(topLevelItem(1)->child(0)->text(0)); // this one has nothing to do with tree
          

          }

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You might be getting the value before it has been transferred to the model

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

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