0
votes

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 of MyWidget it should hide and it works fine, When I click the button inside the widget its getting hide but on clicking the widget (W1) inside the layout MyWidget is not hiding

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

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

Why button click hides MyWidget

1

1 Answers

0
votes

use m_clearButton->setFocusPolicy(Qt::NoFocus);