Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果节点是叶子,我有QTreeView并且我想要多选行为,否则是单选行为,所以如果已经选择了某个节点,则不允许选择非叶子节点,如果非叶子节点,则不允许选择任何其他节点被选中。如何实施?
QTreeView
您可以尝试通过派生QTreeView和重载来控制选择行为selectionCommand。
selectionCommand
使用此方法,您可以检查单击了哪个项目(节点/叶),然后返回正确的SelectionFlags.
SelectionFlags