首先要響應鼠標事件,然後通過 Style Sheets 改變按鈕的外觀1. 從QPushButton派生一個自己的按鈕類2.在新類的構造函數中 調用 mouseTracking(true)以獲取鼠標移動事件。
3、 重載 mouseMoveEvent(),在該函數中通過StyleSheet改變外觀 如: setStyleSheet("background: yellow”) Qt Style Sheets的使用請參考 Assistance中的內容 和 Style Sheet Example