Is it possible to deselect in a QTreeView by clicking off an item?

后端 未结 8 1214
盖世英雄少女心
盖世英雄少女心 2020-12-30 05:35

I\'d like to be able to deselect items in my QTreeView by clicking in a part of the QTreeView with no items in, but I can\'t seem to find anyway of doing this. I\'d intercep

8条回答
  •  旧巷少年郎
    2020-12-30 06:05

    QTreeView inherits from QAbstractView (http://doc.qt.digia.com/4.6/qtreeview.html) which has a clicked signal. The problem is that the signal is emitted only when index is valid so you can not achieve what you want with this signal.

    Try to intercept the mousePressEvent instead. In the function you can find where the user has clicked and deselect selected item if needed.

提交回复
热议问题