Hhry
Hhry

Reputation: 933

Qt5: dynamic add QLabel from buttom to the top

I'm using QVboxLayout to achieve this. The following code below is what I'm currently trying:

BubbleLabel *label = new BubbleLabel();
label->setText(text);
ui->verticalLayout->insertWidget(-1, label);

Instead of from buttom to the top, the result was from top to buttom: enter image description here

I want it to show this way: enter image description here

How can I achieve that?

Upvotes: 0

Views: 42

Answers (1)

Pablo Yaggi
Pablo Yaggi

Reputation: 1231

Insert works with the 'placement location' as index. You should use:

ui->verticalLayout->insertWidget(0, label);

Upvotes: 1

Related Questions