how to notify mouseplacing on a widget is with a color
hai i just want to change the color of the buttons when i move the mouse on it....ie if i place mouse on pushbutton1 i want to chenge its color to green...when i remove the mouse from it i wan开发者_如何学JAVAts the old color....how can i achieve this.....i have many buttons and other widget in my mainwindow....i want for every widget like dis....
thanks in advance
This can be achieved by setting the style sheet of the button.
MyButton.setStyleSheet("*:hover {background: green }");
This will control the color just for the button you apply it to.
If you want all the buttons on a form to have the same behaviour, set the style sheet of the widget containing the buttons instead.
MyWidget.setStyleSheet("QPushButton:hover {background: green }");
Style sheets are a very powerful option for customizing the look of your application. You can find more information here.
精彩评论