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. why QTreeWidget::findItems failed?
Forum Update on Monday, May 27th 2025

why QTreeWidget::findItems failed?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.1k 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.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #1

    why QTreeWidget::findItems failed?
    i set the 1st param to the Text which is the same i setText when it's created,
    and the 2nd param to Qt::Exactly
    3rd param to 0
    but it always return a empty List....

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

      Hi,

      Without any code nor dataset you use it's impossible to tell you why. Did you mean Qt::MatchExactly ?

      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
      • O Offline
        O Offline
        opengpu2
        wrote on last edited by
        #3

        eg. when create QTreeWidgetItem, pTreeWidgetItem->setText(0, "aaa");
        only when this is the root item, i can use findItems get it.
        otherwise, when i use findItems("aaa", Qt::MatchExactly, 0), it return 0.
        should i do sth when the item which i want to find is not a root but a Child Item?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by mcosta
          #4

          Can you post the code?

          TIP: Qt::MatchExactly uses QVariant-based match. If you're sure the type is a string I suggest to use Qt::MatchFixedString

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0
          • O Offline
            O Offline
            opengpu2
            wrote on last edited by
            #5

            Qt::Recursively should be added

            1 Reply Last reply
            1

            • Login

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