Results 1 to 3 of 3

Thread: Qtreewidget not updating data

  1. #1
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qtreewidget not updating data

    Hi All
    I'm writing an application where i'm using tree widget. if i click on the treewidget an input dialog is poping up and asking to enter a string. i need to update that string in treewidget. Below is my code. But its not updating in tree widget. Can ny body help me.

    Qt Code:
    1. bool b;
    2. QString name = QInputDialog::getText( this,
    3. tr( "New name" ),
    4. tr( "Please enter the name " ),
    5. QLineEdit::Normal, tr( "New classroom" ), &b);
    6.  
    7. if(b && !name.isEmpty())
    8. {
    9. QStringList strlist;
    10. strlist.push_back(classroom_name);
    11. QTreeWidgetItem temptreelst(strlist);
    12. m_name.append(&temptreelst); //QList<QTreeWidgetItem *> m_name is to colect the list of names and amember variable
    13. ui->treeWidget->addTopLevelItem(&temptreelst);
    14. ui->treeWidget->expandAll();
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

    Thank u all.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Qtreewidget not updating data

    First, in your code you don't use the asked string name. Second, create your QTreeWidgetItem on the heap, because else it gets deleted after the scope.

  3. #3
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qtreewidget not updating data

    Quote Originally Posted by Lykurg View Post
    First, in your code you don't use the asked string name. Second, create your QTreeWidgetItem on the heap, because else it gets deleted after the scope.
    thank u for quick response. there was ll mistake in the code. Below i've posted the code.

    Qt Code:
    1. bool b;
    2. QString name = QInputDialog::getText( this,
    3. tr( "New name" ),
    4. tr( "Please enter the name " ),
    5. QLineEdit::Normal, tr( "New classroom" ), &b);
    6.  
    7. if(b && !name.isEmpty())
    8. {
    9. QStringList strlist;
    10. strlist.push_back(name );
    11. QTreeWidgetItem temptreelst(strlist);
    12. m_name.append(&temptreelst); //QList<QTreeWidgetItem *> m_name is to colect the list of names and amember variable
    13. ui->treeWidget->addTopLevelItem(&temptreelst);
    14. ui->treeWidget->expandAll();
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

    temptreelst is QTreeWidgetItem object. But still its nt updating.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

Similar Threads

  1. QTreeWidget not updating content...
    By lni in forum Qt Programming
    Replies: 7
    Last Post: 14th August 2010, 16:06
  2. Replies: 5
    Last Post: 12th October 2009, 10:05
  3. Replies: 0
    Last Post: 15th May 2009, 15:12
  4. setting data of buffer to QTreeWidget column
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 17:12
  5. QTreeWidget - Parsing Data.
    By Preeteesh in forum Qt Programming
    Replies: 3
    Last Post: 17th June 2007, 12:57

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.