Thanks so much, wysota !
I totally forgot to connect the Widgets in MyWidget to the parent.
I cleaned it up now:
myWidget.cpp
#include "mywidget.h"
#include <QPushButton>
{
butInMyW->setParent(parent);
}
#include "mywidget.h"
#include <QPushButton>
myWidget::myWidget(QWidget *parent) : QWidget(parent)
{
QPushButton *butInMyW = new QPushButton("Button in myWidget");
butInMyW->setParent(parent);
}
To copy to clipboard, switch view to plain text mode
It still didn't work with simply layout->addWidget(myW) in main.cpp. I guess it doesn't set a parent implicetly when using a custom Widget !? Because when using another Button instead of myWidget it works fine. But now I used an extra QWidget to be parent of myWidget:
here's just a snippet of main.cpp
myWidget *myW = new myWidget(&helpWid);
//QPushButton *myW = new QPushButton("other Button");
layout->addWidget(&helpWid);
QWidget helpWid;
myWidget *myW = new myWidget(&helpWid);
//QPushButton *myW = new QPushButton("other Button");
layout->addWidget(&helpWid);
To copy to clipboard, switch view to plain text mode
Or is there another way without using the extraWidget, did I make another mistake 
Well, I'm glad it works at least this way now. Thanks again wysota !!!
Bookmarks