Results 1 to 3 of 3

Thread: findItems not working with tree

  1. #1
    Join Date
    Sep 2008
    Posts
    54
    Thanks
    3
    Thanked 10 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default findItems not working with tree

    Hello,

    I have created a QTreeWidget with several columns. In the first column I create a tree of QTreeWidgetItems.

    When I use the function findItems on a other column it never returns an list with items for a item that is not the root in the first column.

    So basically it will only find QTreeWidgetItems when the parent is the TreeWidget.

    Am I using this functionallity wrong? I expect to get the other items to regardless of their tree depth?

    Regards,

    Marcel

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: findItems not working with tree

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2008
    Posts
    54
    Thanks
    3
    Thanked 10 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default Re: findItems not working with tree

    In de example below only 1 will be printed.

    const indexColumn (1);

    // Create TreeWidget
    {
    QTreeWidget treeView = new QTreeWidget(parent);
    QTreeWidgetItem *___qtreewidgetitem = listviewSummary->headerItem();
    ___qtreewidgetitem->setText(0, QApplication::translate("Name", "Id", 0, QApplication::UnicodeUTF8));
    ___qtreewidgetitem->setText(1, QApplication::translate("Name", "TestName", 0, QApplication::UnicodeUTF8));
    }

    // Fill TreeWidget with one tree
    {
    TreeWidgetItem item1 = new TreeWidgetItem (treeView);
    item1.setText (indexColumn, QString("1"));
    TreeWidgetItem item2 = new TreeWidgetItem (item1);
    item2.setText (indexColumn, QString("2"));
    TreeWidgetItem item3 = new TreeWidgetItem (item2);
    item3.setText (indexColumn, QString("3"));
    }

    // Loop TreeWidget
    {
    for (int index (0) ; index < 5 ; ++index)
    {
    // Bug in QT (187598 & 88548)
    // Because column not equals 0 all childItems are not found. Root item is found.
    QList<QTreeWidgetItem *> treeWidgetItemList (findItems ( QString ("%1").arg (index), Qt::MatchContains, indexColumn));

    if (!treeWidgetItemList.isEmpty ())
    {
    qWarning ("Index: %d", treeWidgetItemList.first ().text (indexColumn));
    }
    }
    }

    Existing bugs already mentioned in QT bugtracker:

    http://qt.nokia.com/developer/task-t...entry&id=85548

    http://qt.nokia.com/developer/task-t...ntry&id=187598

Similar Threads

  1. Writing a Tree model.
    By kaushal_gaurav in forum Qt Programming
    Replies: 6
    Last Post: 16th January 2009, 11:22
  2. creating a Tree
    By mickey in forum General Programming
    Replies: 0
    Last Post: 20th April 2008, 17:57
  3. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31
  4. Replies: 3
    Last Post: 19th April 2007, 11:42
  5. Optimizing filterAcceptsRow() to filter a tree
    By vfernandez in forum Qt Programming
    Replies: 1
    Last Post: 4th January 2007, 12:50

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.