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 highlight item without mouse click
Forum Updated to NodeBB v4.3 + New Features

QTreeWidget highlight item without mouse click

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 486 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.
  • B Offline
    B Offline
    BoGut
    wrote on last edited by
    #1

    Hello fellow QT'ers, hope you're all doing well. I have a weird question: I have a QTreeWidget that works well when I mouse click on an item. Is it possible to emulate this click with code? I tried this

    foreach(QTreeWidgetItem * object, ui.listTree->selectedItems()) {
    	ui.listTree->setCurrentItem(object);
    	ui.listTree->currentItem()->setSelected(true);
    }
    

    and it doesn't select the item at all. I looked at the SelectionMode and it's set to ExtendedSelection.

    Thanks

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @BoGut said in QTreeWidget highlight item without mouse click:

      ui.listTree->selectedItems()

      You're aware what this function does?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      B 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        @BoGut said in QTreeWidget highlight item without mouse click:

        ui.listTree->selectedItems()

        You're aware what this function does?

        B Offline
        B Offline
        BoGut
        wrote on last edited by
        #3

        @Christian-Ehrlicher guess I need more sleep, good catch!

        1 Reply Last reply
        0

        • Login

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