currentRowChanged 的注意事項

2022-06-11 14:42:09 字數 635 閱讀 8161

qt中的表單控制項qlistwidget類提供了許多訊號函式,可以和使用者互動,其中有個currentrowchanged ( int currentrow ) 是檢測當前選中行是否發生了改變,如果改變了,該訊號函式被觸發。

void qlistwidget::currentrowchanged ( int

currentrow ) [signal]

this signal is emitted whenever the current item changes.

currentrow is the row of the current item. if there is no current item, the currentrow is -1.

我們要注意的是最後一句話,當沒有當前項時,currentrow 賦值為-1,由於有這點存在,所以再寫該訊號函式的內容開始,一定要先判斷currentrow的值是否大於等於0,若忽略了這一步,在下面直接用currentrow當做引數取訪問陣列時會出錯,而通常這錯誤得費老半天勁才能找的出來,正確寫法如下:

void yourclass::on_lwidget_currentrowchanged(int

currentrow)

}

currentRowChanged 的注意事項

qt中的表單控制項qlistwidget類提供了許多訊號函式,可以和使用者互動,其中有個currentrowchanged int currentrow 是檢測當前選中行是否發生了改變,如果改變了,該訊號函式被觸發。void qlistwidget currentrowchanged int cur...

CWnd SetWindowPos的注意事項

函式原型 bool cwnd setwindowpos const cwnd pwndinsertafter,插入的地方 int x,水平座標 int y,垂直座標 int cx,寬 int cy,高 uint nflags 視窗定位標識 說明 這個函式能改變視窗的大小 位置和設定子視窗 彈出視窗或...

pytorch fine tuning注意事項

前言 這篇文章算是論壇pytorch forums關於引數初始化和finetune的總結,也是我在寫 中用的算是 最佳實踐 吧。最後希望大家沒事多逛逛論壇,有很多高質量的回答。引數初始化 引數的初始化其實就是對引數賦值。而我們需要學習的引數其實都是variable,它其實是對tensor的封裝,同時...