Solved Modify hit box of QRadioButton (SE_RadioButtonClickRect)
-
Hi all,
currently I'm struggling with the following task: I want slightly increase the hit box around the QRadioButton. (The area where you can activate the button.)
The "hit box" has several rules to fullfil in QRadioButton::mouseMoveEvent like underMouse or hitButton. The ClickRect is filled in QStyleOption::initFrom aka init by using widget->rect(). Qt doc says in QWidget::rect():
The rect property equals QRect(0, 0, width(), height()).
Means that I only need to call for example setMinimumSize, setGeometry or resize to increase it, but for me it doesn't work (from Qt4.7.X up to Qt5.X).I also derived QRadioButton and adjusted minimumSizeHint and sizeHint which doesn't had any impact towards the hit box.
Any ideas?
Kind regards,
Mike -
Hi,
Can you show your code ? Without it it's pretty much "Crystal Ball Debugging".
-
Hi
One way is#include <QProxyStyle> class MyStyle : public QProxyStyle { virtual QRect subElementRect(SubElement subElement, const QStyleOption*opt , const QWidget* widget) const override { if ( subElement == SE_RadioButtonClickRect && widget) return widget->rect(); else return QProxyStyle::subElementRect( subElement,opt,widget) ; } }; ui->radioButton->setStyle( new MyStyle );
-