I want to dynamically create a child widget on the click of the mouse. When I manually create it in ctor, everything is ok.
Foo::Foo(QWidget *partent) : QWidget(parent)
{
auto *txt{ new QPlainTextEdit(this) };
}
but when I do the same in mousePressEvent, it doesn't appear.
Foo::mousePressEvent(QMouseEvent *event)
{
auto *txt{ new QPlainTextEdit(this) };
QWidget::mousePressEvent(event);
}
What might be the problem? Is there something in the ctor that triggers the appearance of the widget?