How to resize the QToolButton
when focus is coming on that QToolButton.
I am having 5 QToolButton
, when focus is coming on 2nd QTool
You will have to make a custom class , subclassing QToolButton.
class MyButton : public QToolButton
{
Q_OBJECT
private:
int originalWidth, originalHeight;
int bigWidth, bigHeight;
};
And then reimplement the focusInEvent and out.
void focusInEvent ( QFocusEvent * event ) {
resize(bigWidth,bigHeight);
QToolButton::focusInEvent(event); // Don't forget to call parent focus in / out in order to make the "hover" effect work.
}
void focusOutEvent ( QFocusEvent * event ) {
resize(originalWidth,originalHeight);
QToolButton::focusOutEvent(event);
}
Cheers.
It is also possible via QSS:
#MySecondButton:focus
{
width: 300px;
height: 200px;
}
Depends on layouting and size policy it may require to set "max-width" / "max-height" / "min-width" etc, properties.