I'm not sure if i understood your problem.
You want to associate treeWidgetItems with message types without coding?