Results 1 to 2 of 2

Thread: QTreeWidget Problems

  1. #1
    Join Date
    Dec 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget Problems

    I'm wanting to unselect the only (1) selected item in my QTreeWidget,
    but when I use my code, It returns:

    ASSERT failure in QList<T>::at: "index out of range", file /usr/include/qt4/QtCore/qlist.h, line 439

    Here is my code:
    Qt Code:
    1. if(ui->treeWidget->selectedItems().count()>0)
    2. {
    3. QTreeWidgetItem *i = ui->treeWidget->selectedItems().first();
    4. i->setSelected(0);
    5. }
    To copy to clipboard, switch view to plain text mode 

    Is there something wrong with my code? It looks right to me...


    Added after 1 41 minutes:


    It seems to me that there is something wrong with the QTreeWidget. But I'm not sure.
    Last edited by Ryan Riffle; 16th January 2011 at 04:12.

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QTreeWidget Problems

    Your code worked fine for me in a simple test program even with multiple selections.

    I'm wanting to unselect the only (1) selected item in my QTreeWidget
    If you only allow single selections you could use
    Qt Code:
    1. ui->treeWidget->selectionModel()->clear();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 2
    Last Post: 23rd July 2010, 14:53
  2. Replies: 3
    Last Post: 22nd March 2010, 13:50
  3. Replies: 2
    Last Post: 17th March 2008, 12:53
  4. Replies: 1
    Last Post: 19th October 2007, 01:29
  5. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39

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.