开发者

QSlider focus issue (Mac Leopard) with QApplication::focusChanged(QWidget*,QWidget*)

开发者 https://www.devze.com 2022-12-13 23:24 出处:网络
I\'m using Qt 4.6.0 in Leopard 10.5.8. I have a few sliders. Every time I slide/click on a slider, it gets focus in Windows. However, it does not get focus on Mac. I have to manually click Ta开发者_St

I'm using Qt 4.6.0 in Leopard 10.5.8. I have a few sliders. Every time I slide/click on a slider, it gets focus in Windows. However, it does not get focus on Mac. I have to manually click Ta开发者_StackOverflow社区b to change focus. How to rectify this? Thanks in advance!


I just had to re-implement the event QWidget::mousePressEvent ( QMouseEvent * event ) :

void MyChildWidget::mousePressEvent ( QMouseEvent * event )
{
    //event->accept();
    this->setFocus(Qt::TabFocusReason);
    event->ignore();

    // give control to the parent
    QSlider::mousePressEvent(event);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消