In the following code there is clearly enough space for the label to fit on one line, but for some reason it splits it into two lines after 'thats'. Why and how do I prevent this?
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
this->setFixedSize(250,100);
QLabel *label = new QLabel;
label->setStyleSheet("background-color:blue");
label->setWordWrap(true);
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
label->setText("Oh my gosh thats too funny!");
label->setParent(this);
}
Again for clarity, it shows:
Oh my gosh thats too funny!
And I want:
Oh my gosh thats too funny!
label->setWordWrap(false);
??? If it's not a typo then I think you have an answer. From Qt docs: "If this property is true then label text is wrapped where necessary at word-breaks; otherwise it is not wrapped at all." – docQVBoxLayout * layout = new QVBoxLayout; layout->addWidget(label); this->setLayout(layout);
. The QWidget does not reposition and resize its child widgets by itself. – doc