PNP_PIbd-31_Rodionov_I_A_Co.../utils/buttonhoverwatcher.cpp
2024-12-24 18:13:22 +04:00

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;
}