將QTreeWidget事件的itemExpanded信號自己編寫的槽函數鏈接起來,槽函數中只要把其它的item閉合就好。
槽函數:
int nCount = this->topLevelItemCount();
for(int i=0; i<nCount;i++) {
if (item != this->topLevelItem(nCount)) {
this->collapseItem(this->topLevelItem(nCount));
}
}
將QTreeWidget事件的itemExpanded信號自己編寫的槽函數鏈接起來,槽函數中只要把其它的item閉合就好。
槽函數:
int nCount = this->topLevelItemCount();
for(int i=0; i<nCount;i++) {
if (item != this->topLevelItem(nCount)) {
this->collapseItem(this->topLevelItem(nCount));
}
}
數組求和 方法一:直接一次for循環 int GetSum1(int *a,int n) { int sum=0; for (int i=0; i<n;i++) { sum+=a[i];