Widget focusOutEvent event is called before button press inside widget



  • I have a class(MyWidget) inherited from QWidget and inside it I created a button and other widget (say W1), Both kept inside QVBoxLayout

    On focusOutEvent widget(MyWidget) should hide and it works fine, but when I click the button inside the widget its getting hide but on clicking the widget (W1) inside the layout its not hiding

    m_layout = new QVBoxLayout(widget);
    m_clearButton = new QPushButton(widget);
    m_layout->addWidget(m_clearButton,0,Qt::AlignRight)

    // this widget on click main widget is not hiding
    m_layout->insertWidget(m_layout->count() -1,item);

    Why button click hides MyWidget


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Because when you click on the button the focus moves to the button so out of your other widget.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.