PDA

View Full Version : How to highlight a QWidget



AndreiTuicu
14th May 2014, 23:14
Hello everyone! Here is my question:

I've derived the QToolButton so that buttons in QToolBar can be accessed by tabbing, but when it gains focus it is not highlighted like when i hover with the cursor over it. I've overriden the focusInEvent function, but when it comes to actually highlighting the button I don't know what property/attribute to set or what method to call.

Here is what it looks like when I hover with the cursor over the button:
10361
How can I achieve this by replacing the line marked?

Here is what is currently happening:
10362



void focusInEvent(QFocusEvent* e){
if(e->gotFocus() && e->reason() == Qt::TabFocusReason){
setGraphicsEffect(new QGraphicsColorizeEffect()); //line to be replaced
}
QToolButton::focusInEvent(e);
}


Thank you for your help! :)

Rajesh.Rathod
21st May 2014, 08:08
Try style sheet for the widget focus, see below style sheet example for QWidget focus...

QWidget:focus {border: 3px solid green;}