I want to sort the tree widget based on the user data not the text displayed in the tree widget. How can i do this? MFC has the function SetItemData for the controls where we can store the user data in the nodes. How can i achieve this in QT. For example I want to display the names but it has to be sorted on age corresponding to name (which is user data).