Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Selecting item in QML TreeView does not change isSelected of item
Forum Updated to NodeBB v4.3 + New Features

Selecting item in QML TreeView does not change isSelected of item

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 478 Views 1 Watching
  • 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.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by ocgltd
    #1

    I have created a simple TreeView in QML, with several levels of nesting. I have also created an "itemDelegate" and a "rowDelegate"; both of which switch background color between red/black bound to their respective isSelected.

    When I click on an item the ROW color changes, but the item does not. I confirmed the itemFlag for each item includes ItemsIsSelectable and ItemIsEnabled (default).

    My itemDelegate contains:

    Rectangle {
                       color: styleData.isSelected ? "red" : "black"
    

    I added a selection to the treeview:

    ItemSelectionModel {
              id: treeViewSelectionModel
              objectName: "treeViewSelectionModel"
              model: treemodel
              onCurrentChanged:{console.log("Selection - current changed from ",previous, " to ", current)}
          }
    

    Which correctly prints out the new/previous selection. So it appears the item is being selected, but not changing color (the isSelected never changes for the item). Can someone explain why?

    1 Reply Last reply
    0
    • ocgltdO Offline
      ocgltdO Offline
      ocgltd
      wrote on last edited by
      #2

      Problem is inconsistency in how QML names its methods. Some are "isSelected" (eg ROW), or "isExpanded" (ITEM), but item uses "selected" instead of "isSelected"

      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