you should do something like this
class YourButton : public QToolButton
{
Q_OBJECT
protected:
void focusInEvent(QFocusEvent* e);
void focusOutEvent(QFocusEvent* e);
};
in .cpp file
void YourButton::focusInEvent(QFocusEvent* e)
{
if (e->reason() == Qt::MouseFocusReason)
{
// Resize the geometry -> resize(bigWidth,bigHeight);
}
QToolButton::focusInEvent(e);
}
then use the yourButton class in your mainWindow.
also (another option) you can use http://qt-project.org/doc/qt-4.8/qobject.html#installEventFilter in your mainWindow .