Subclassing the QTreeView class to register fields in a QWizard



  • Hi all,

    I'm very new to Qt and I've been stucked for a while now.
    I decided to build a GUI based on a QWizard. In such a context, parameters are passed from one QWizardPage to another via the parameters registration process. This is pretty much straightforward, excepted when using objects that are not 'registrable' by-design. In my case, I have a QTreeView inside a QWizardPage. I need to register the user-selected directory so that to launch processings in the final step. It seems the only solution is to subclass the QTreeView class. I tried but I wasn't able to get it working. Any help on this ?

    Thanks a lot by advance.



  • You don't have to subclass. I request to go through how QTreeView can be used with models. QTreeView emits signals like the following whenever you select on treeview.

    e.g
    @void activated(const QModelIndex & index)
    void clicked(const QModelIndex & index)@

    Using index, you can query the data(filename) and store at some temp variables. You can use this temp variable where ever you want.



  • Hi Dheerendra, thanks a lot for your answer.
    This is an alternative I definitely have to consider.
    Anyway, I'm still interested in having a better knowledge of subclassing given such a context.



  • This is not alternative. It the way it supposed to be used. If you need any additional functions apart from what is provided in QTreeView, then you need to subclass it. In the current scenario, I don't see the reason for you to subclass it.


  • Lifetime Qt Champion

    Hi,

    You should only need to add a QString property to your subclass and implement the corresponding function to register your custom QTreeView.

    What did not work ?


Log in to reply
 

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