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. Mouse click event on children of qt tree item widget

Mouse click event on children of qt tree item widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 2.0k Views 2 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.
  • C Offline
    C Offline
    cymric97
    wrote on last edited by
    #1

    I want to create a mouse click event on children items of a certain qt tree widget item. Is there a simple way i can do that with a qt tree widget item?

    I would like to click on one of the children such that when I click on it I can retrieve the text data of that selected child.

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by Kent-Dorfman
      #2

      Look at the signals for QTreeWidget. One already exists for clicking on an item.

      If you meet the AI on the road, kill it.

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to the forums.
        You can easily do that with
        https://doc.qt.io/qt-5/qtreewidget.html#itemClicked
        and use item->Text()

        1 Reply Last reply
        2
        • C Offline
          C Offline
          cymric97
          wrote on last edited by
          #4

          I have added a checkbox to each tree widget item, how can i catch the event when one checkbox has been checked or unchecked?

          mrjjM 1 Reply Last reply
          0
          • C cymric97

            I have added a checkbox to each tree widget item, how can i catch the event when one checkbox has been checked or unchecked?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @cymric97
            Hi
            You mean like a real qcombobox ?
            With setCellWidget ?
            If yes, you need to hook it up to a slot, like you normally.

            You could also do ( when you create item)
            item->setFlags(item->flags() | Qt::ItemIsUserCheckable |Qt::ItemIsSelectable);

            and then you can directly check with
            https://doc.qt.io/qt-5/qtreewidgetitem.html#checkState
            or hook up to
            https://doc.qt.io/qt-5/qtreewidget.html#itemChanged
            to be notified when checked state changes for an item.

            1 Reply Last reply
            2

            • Login

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