Only QObjects(objects of classes that inherits QObject) can be named by setObjectName.
QTreeWidgetItem is not a QObject, so
i think you'll have to code it.
If you don't want to maintain additional code for it, consider reading massages types from kind of text file or xml.
Bookmarks