Qt 【关于控件样式,鼠标进入、离开、点击】
比如舉以下這個例子:
?
QPushButton * okBtn;
?
okBtn->setstylesheet("QPushButton{border-image:url(:/image/hello);}"); ? ? ? ? ? ? //這個是最常規(guī)的樣式
?
okBtn->setstylesheet("QPushButton{border-image:url(:/image/hello);}" ? ? ? ? ? ? ? //常規(guī)的樣式
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"QPushButton:hover{border-image:url(:/image/hello);}"); ? //鼠標進入后Btn的樣式
?
okBtn->setstylesheet("QPushButton{border-image:url(:/image/hello);}" ? ? ? ? ? ? ? //常規(guī)的樣式
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"QPushButton:hover{border-image:url(:/image/hello);}" ? ? ?//鼠標進入后Btn的樣式
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"QPushButton:pressed{border-image:url(:/image/hello);}" ); ?//鼠標點擊的樣式
?
注意這里的 位置是固定的不能隨意改變,更改hover與pressed的位置會導致樣式設置失敗,可以少寫一個樣式如第二步,但是不能多寫或者打亂順序。
?
轉(zhuǎn)載于:https://www.cnblogs.com/liuruoqian/p/5416669.html
總結
以上是生活随笔為你收集整理的Qt 【关于控件样式,鼠标进入、离开、点击】的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 同意条款按钮可用
- 下一篇: Git工作流指南:集中式工作流