
Originally Posted by
Lesiok
As I see class MyWidget is inherited from QFrame. So for what is QFrame *baseWidget ?
Yes, that is the problem you see. I want this to be baseWidget. So that the parent of this (or baseWidget) is the parent widget I pass in as parameter. How do I do it?

Originally Posted by
ChrisW67
BaseWidget is positioned in the top left because you gave it the MyWidget instance as a parent and, I am guessing, did not put it in a layout applied to the MyWidget instance. What is the function of baseWidget? Have you put other widgets inside it instead of inside the MyWidget container? It certainly sounds like that from your questions.
Yes, baseWidget will have lots of sub-widgets in it. I pass in the parent because it has to be positioned at a particular position in the parent widget, layout agnostic. If I do
baseWidget->setGeometry(x,y,width,height);
//add more widgets to baseWidget
QFrame *baseWidget = new QFrame(this);
baseWidget->setGeometry(x,y,width,height);
//add more widgets to baseWidget
To copy to clipboard, switch view to plain text mode
in the parent widget code, it works fine. I want to do the same things, except baseWidget will be of type MyWidget that inherits from QFrame.
Bookmarks