V. Lad
V. Lad

Reputation: 27

PyQt5 - set toolTip for each QTreeWidgetItem

I have a GUI that uses a QTreeWidget to load a list of key - value pairs from a JSON file.

My question is if it's possible to set a tooltip for every item (just the keys) of the QTreeWidget?

P.S. I would like to keep the tree widget and do not move to QTreeView.

Upvotes: 0

Views: 2503

Answers (1)

ekhumoro
ekhumoro

Reputation: 120718

You could easily answer a questions like this by looking at the documentation for QTreeWidgetItem:

void QTreeWidgetItem::setToolTip(int column, const QString &toolTip)

Sets the tooltip for the given column to toolTip.

Which in PyQt5 will simply be:

item = QTreeWidgetItem(key)
item.setToolTip(0, 'some text')

Upvotes: 1

Related Questions