Hi,
currently I am trying to achieve something like this:
Untitled.jpg
So red widget is centralWidget of my QMainWindow and now I want to add another small widget (yellow one) inside it and put it in bottom left corner.
If I do something like this
red->setStyleSheet("background:red;");
red->setMaximumSize(400, 400);
layout->addWidget(red);
MyCustomWidget* mainWidget = new MyCustomWidget(this);
mainWidget->setLayout(layout);
setCentralWidget(mainWidget);
QHBoxLayout* layout = new QHBoxLayout(this);
QWidget* red = new QWidget(this);
red->setStyleSheet("background:red;");
red->setMaximumSize(400, 400);
layout->addWidget(red);
MyCustomWidget* mainWidget = new MyCustomWidget(this);
mainWidget->setLayout(layout);
setCentralWidget(mainWidget);
To copy to clipboard, switch view to plain text mode
I see my widget but it's centered vertically and horizontally inside my MyCustomWidget.
If I try changing "addWidget" line to :
layout->addWidget(red, 0, Qt::AlignLeft | Qt::AlignBottom);
layout->addWidget(red, 0, Qt::AlignLeft | Qt::AlignBottom);
To copy to clipboard, switch view to plain text mode
I don't see my widget anymore.
Could someone tell me why is it happening and how can I fix it?
Is my approach good?
Bookmarks