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()

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 31 Dec 2015, 20:32 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 31 Dec 2015, 21:05 last edited by Lorence
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 31 Dec 2015, 21:51 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 1 Jan 2016, 12:34
        0
        • S SGaist
          31 Dec 2015, 21:51

          Hi,

          Where are you calling that qDebug ?

          L Offline
          L Offline
          Lorence
          wrote on 1 Jan 2016, 12:34 last edited by Lorence 1 Jan 2016, 13:16
          #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
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 1 Jan 2016, 18:25 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

            5/5

            1 Jan 2016, 18:25

            • Login

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