Create an event filter and install it on the 10th pushbutton. In the event filter, examine the event to see if it is a "focusIn" event. If so, then emit a signal to change the text of your buttons.
It will work something like this:
// FocusFilter.h
{
Q_OBJECT
signals:
void focusInReceived();
protected:
};
// FocusFilter.cpp
{
if ( pEv
->type
() == QEvent::FocusIn ) emit focusInReceived();
return QObject::eventFilter( pObj, pEv
);
}
// YourGUICode.cpp
FocusFilter * pFF = new FocusFilter( this );
connect( pFF, SIGNAL( focusInReceived() ), this, SLOT( refresh() ) );
pushbutton[ 9 ]->installEventFilter( pFF );
// FocusFilter.h
class FocusFilter : public QObject
{
Q_OBJECT
signals:
void focusInReceived();
protected:
bool eventFilter( QObject * pObj, QEvent * pEv );
};
// FocusFilter.cpp
bool FocusFilter::eventFilter( QObject * pEv, QEvent * pEv )
{
if ( pEv->type() == QEvent::FocusIn )
emit focusInReceived();
return QObject::eventFilter( pObj, pEv );
}
// YourGUICode.cpp
FocusFilter * pFF = new FocusFilter( this );
connect( pFF, SIGNAL( focusInReceived() ), this, SLOT( refresh() ) );
pushbutton[ 9 ] = new QPushButton( this );
pushbutton[ 9 ]->installEventFilter( pFF );
To copy to clipboard, switch view to plain text mode
Not compiled or tested, but this should do what you want.
Bookmarks