PNP_PIbd-31_Rodionov_I_A_Co.../utils/buttonhoverwatcher.cpp

25 lines
569 B
C++
Raw Permalink Normal View History

2024-12-24 18:13:22 +04:00
#include "buttonhoverwatcher.h"
ButtonHoverWatcher::ButtonHoverWatcher(QObject *parent) : QObject(parent)
{}
bool ButtonHoverWatcher::eventFilter(QObject *watched, QEvent *event)
{
2025-01-14 21:33:47 +04:00
QPushButton *button = qobject_cast<QPushButton*>(watched);
2024-12-24 18:13:22 +04:00
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;
}