25 lines
570 B
C++
25 lines
570 B
C++
#include "buttonhoverwatcher.h"
|
|
|
|
ButtonHoverWatcher::ButtonHoverWatcher(QObject *parent) : QObject(parent)
|
|
{}
|
|
|
|
bool ButtonHoverWatcher::eventFilter(QObject *watched, QEvent *event)
|
|
{
|
|
QPushButton * button = qobject_cast<QPushButton*>(watched);
|
|
if (!button) {
|
|
return false;
|
|
}
|
|
|
|
if (event->type() == QEvent::Enter) {
|
|
button->setIcon(QIcon(":/images/search-hover.png"));
|
|
return true;
|
|
}
|
|
|
|
if (event->type() == QEvent::Leave){
|
|
button->setIcon(QIcon(":/images/search.png"));
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|