QT的QTreeWidget同時只展開一項

將QTreeWidget事件的itemExpanded信號自己編寫的槽函數鏈接起來,槽函數中只要把其它的item閉合就好。
槽函數:
int nCount = this->topLevelItemCount();
for(int i=0; i<nCount;i++) {
    if (item != this->topLevelItem(nCount)) {
        this->collapseItem(this->topLevelItem(nCount));
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章