I would like to highlight a QFrame, if one of it's child widgets has focus (so the users know where to look for the cursor ;-)
using something along
ui->frame->setFocusPolicy(Qt::StrongFocus);
ui->frame->setStyleSheet("QFrame:focus {background-color: #FFFFCC;}");
highlights the QFrame when I click on it, but it loses its focus once one of its child widgets is selected.
Possible approaches:
I could
connect()
QApplication::focusChanged(old,now)
and check each new object if it is a child of my QFrame, but this gets messy.I could also subclass each child widget and reimplement
focusInEvent()
/focusOutEvent()
and react on that, but with a lot of different widgets, this is also a lot of work.
Is there a more elegant solution?