[Solved] Use of focusWidget()
-
Hi
I am trying to find which of the buttons has the focus and do an animateClick() on it.
@QWidget *focused_widget;
focused_widget = QWidget::focusWidget();
focused_widget->animateClick(ANIMATE_CLICK_TIME);@..does not work and returns: 'class QWidget' has no member named 'animateClick'
Can I somehow casting the widget type or how do I solve this?Thanks
-
@
YourClass *focused_widget;focused_widget = q_object_cast<YourClass>(QWidget::focusWidget());
focused_widget->animateClick(ANIMATE_CLICK_TIME);
@ -
Waaait, QWidget::focusWidget() is not a static method! You need to run it either on your top-level widget, or go with QApplication::focusWidget(). And of course, I forgot to add a pointer in my cast:
@
focused_widget = q_object_cast<YourClass *>(QWidget::focusWidget());
@