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. Help with treeWidget. How to connect each children with another object?
QtWS25 Last Chance

Help with treeWidget. How to connect each children with another object?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.4k 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.
  • C Offline
    C Offline
    ChusMatesanz
    wrote on last edited by ChusMatesanz
    #1

    Hello to everyone,

    This is my first message in this forum. I am very new in Qt and I need some help. I apologize if the answer to my question is to obvious. I am in a little hurry because is for my Thesis, I will appreciate any help.

    I am trying to create a mainWindow in which I set a TreeWidget. The tree widget has three parents in which there are at least two children in just one column (pretty simple). I want to make each child show an enable different actions.

    How I can filter the index by clicking to provide different actions with a conditional sentence? I just need the general way to perform and maybe an example.

    Thank you very much for your help.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Sorry but I didn't really get what you need, could you show us an example of what you'd want?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChusMatesanz
        wrote on last edited by
        #3

        Something very simple, just like in the Qt Creator IDE. I want to make my Qt application to display different elements (like the file editor) when I click in the different elements of the tree.

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

          Hi and welcome to devnet,

          Usually you react to the activated signal and do what you want based on the QModelIndex passed as argument.

          Since you are using a QTreeWidget, then the currentItemChanged might be more fitting to your needs.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi and welcome to devnet,

            Usually you react to the activated signal and do what you want based on the QModelIndex passed as argument.

            Since you are using a QTreeWidget, then the currentItemChanged might be more fitting to your needs.

            C Offline
            C Offline
            ChusMatesanz
            wrote on last edited by
            #5

            @SGaist Thank you very much for your answer. However, how can I set the currentItemChanged?

            How the code differentiate the different items? How can I implement that?

            Sorry for the silly questions

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

              You don't implement a signal. Please take a look at the signals and slots chapter or Qt's documentation.

              As for the differentiation, each item has a different content so it's up to you act on the content of your items.

              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
              1

              • Login

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