Qt TreeView點選空白處時取消已選擇項

2022-09-04 19:51:10 字數 296 閱讀 2608

需求:在treeview列表中空白處點選滑鼠時能取消當前已經選中的專案。

查文件,發現與滑鼠點選相關的訊號只有pressed和clicked。而它們僅在點選有資料的地方時才會觸發,點空白處是不會觸發的。

最後發現只能自己繼承qtreeview控制項去實現mousepressevent邏輯才能辦到

void mytreeview::mousepressevent(qmouseevent* event)

else

}

然後將已有元件提公升為mytreeview即可。

點選按鈕顯示,點選空白處隱藏

html text align center 多數情況下,8個領域中除了知識常識外的其他7個領域,都應優先學習 各個領域中的核心類技能優先學習,核心類技能中,技能年齡小的優先學習。button class xiaotieshi id btnshow value 選課貼士 js function 按鈕...

JS實現點選空白處彈窗消失

doctype html html lang en head meta charset utf 8 meta name viewport content width device width,initial scale 1.0 title 點選空白處彈窗消失 title style input te...

點選隱藏顯示和點選body空白處隱藏

doctype html html lang en head meta charset utf 8 title document title style type text css btn pop style head body a href j ascript class btn 點選 a div...