View Full Version : "Autosize" QLabel according to text?
Raadush
24th May 2012, 10:21
Hi, I have this problem. I have form with QVBoxLayout on it and in this layout i have QLabel and another QWidget with some other elements inside. The problem is, that QLabel and QWidget both take half the size of the form, so I have line of text in QLabel, then much unwanted white space and then QWidget. I don't want to set maximal label size because I use this QLabel to diplay other text in many other places. Is there some way out of this?
try to play with sizepolicy
Raadush
24th May 2012, 10:57
Ok, with setting sizepolicy of QWidget to expanding I forced QLabel to shrink to minimal size. But now I have problem inside QWidget because all elements(labels, combo boxes, input boxes) were accordingly spaced to take all size of QWidget so I have one element, unwanted white space, other element, unwanted white space and so on. I tried to setSpacing(), setAlignment() for QWidget layout with no luck :/
remove sizepolicy and try to add a stretch below the layout.
QVboxLayout *vl = new ....;
vl->addWidget(label);
vl->addWidget(widget);
vl->addStretch();
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.