Thanks, after setting layout's size constraint to QLayout::SetFixedSize everything works as expected.
But without it and when using adjustSize I'm getting strange sequence of sizes which you can see in the attached screenshots. The code which produces it:
if(!_messagesFrame && _worldView) {
_messagesFrame
= new QFrame(_worldView
);
_messagesFrame
->setFrameShape
(QFrame::StyledPanel);
_messagesFrame->setStyleSheet("border: 2px solid #8f8f91; border-radius: 6px; background-color: #e0e0e0; ");
_messagesFrame->move(15,15);
_messagesLayout->setContentsMargins(2,0,2,0);
}
layout->setContentsMargins(0,0,0,0);
layout->addWidget(label);
_messagesLayout->addWidget(widget);
_messagesFrame->show();
_messagesFrame->adjustSize();
if(!_messagesFrame && _worldView) {
_messagesFrame = new QFrame(_worldView);
_messagesFrame->setFrameShape(QFrame::StyledPanel);
_messagesFrame->setStyleSheet("border: 2px solid #8f8f91; border-radius: 6px; background-color: #e0e0e0; ");
_messagesFrame->move(15,15);
_messagesLayout = new QVBoxLayout(_messagesFrame);
_messagesLayout->setContentsMargins(2,0,2,0);
}
QWidget* widget = new QWidget(_messagesFrame);
QLabel* label = new QLabel(text, widget);
QHBoxLayout* layout = new QHBoxLayout(widget);
layout->setContentsMargins(0,0,0,0);
layout->addWidget(label);
_messagesLayout->addWidget(widget);
_messagesFrame->show();
_messagesFrame->adjustSize();
To copy to clipboard, switch view to plain text mode
Bookmarks