PDA

View Full Version : how to call a function when i enter and leave a qpushbutton



athulms
19th October 2011, 11:34
how to call a function when i enter and leave a qpushbutton.
I have to change the style sheet on enter and leave of pushbutton.
It works in stylesheets

ui->savename->setStyleSheet("QPushButton{background-repeat:no-repeat; background:none; border:none; background-image: url(images/PlayernamesaveOff.png);} QPushButton:hover{background-repeat:no-repeat; background:none; border:none; background-image:url(images/PlayernamesaveOn.png)};");


when i resize my window resize event is called. I resize event i change the size of my pushbutton also.Since the picture does not resize i used seticon property and set the image as scaled pixmap. Its works but i cannot apply the mouse over and leave effects

stampede
19th October 2011, 18:09
how to call a function when i enter and leave a qpushbutton.
Reimplement QWidget::enterEvent (http://doc.qt.nokia.com/stable/qwidget.html#enterEvent) and QWidget::leaveEvent (http://doc.qt.nokia.com/stable/qwidget.html#leaveEvent)

athulms
20th October 2011, 05:44
how can i reimplement enterevent. Some more help needed pls... example codes???

stampede
20th October 2011, 08:14
Create a subclass of QPushButton and re-define needed methods there, its basic C++ ;)

athulms
20th October 2011, 11:24
k fine i will do it