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



  • 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.



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



  • 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.


  • Lifetime Qt Champion

    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.



  • @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


  • Lifetime Qt Champion

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.