Qt 【關於控件樣式,鼠標進入、離開、點擊】


比如舉以下這個例子:

 

QPushButton * okBtn;

 

okBtn->setstylesheet("QPushButton{border-image:url(:/image/hello);}");             //這個是最常規的樣式

 

okBtn->setstylesheet("QPushButton{border-image:url(:/image/hello);}"               //常規的樣式

                               "QPushButton:hover{border-image:url(:/image/hello);}");   //鼠標進入后Btn的樣式

 

okBtn->setstylesheet("QPushButton{border-image:url(:/image/hello);}"               //常規的樣式

                               "QPushButton:hover{border-image:url(:/image/hello);}"      //鼠標進入后Btn的樣式

                               "QPushButton:pressed{border-image:url(:/image/hello);}" );  //鼠標點擊的樣式

 

注意這里的 位置是固定的不能隨意改變,更改hover與pressed的位置會導致樣式設置失敗,可以少寫一個樣式如第二步,但是不能多寫或者打亂順序。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM