Alberto
Alberto

Reputation: 12929

QComboBox not aligning to right

I have a QHBoxLayout and i want to add some children to the right, and other to the left:

label = new QLabel(...);
layout->addItem(label);
layout->setAlignment(label, Qt::AlignLeft);
select = new QComboBox(...);
layout->addItem(select);
layout->setAlignment(select, Qt::AlignRight);

However select is not been aligned to the right... any idea?

Neither with QCheckBox and QLabel, but works properly using QSlider

Upvotes: 0

Views: 382

Answers (1)

Ramesh Choudhary
Ramesh Choudhary

Reputation: 426

QHBoxLayout * layout = new QHBoxLayout(this);
QLabel * label = new QLabel("this is label");
layout->addWidget(label, Qt::AlignLeft);
layout->setAlignment(label, Qt::AlignLeft);
QComboBox * select = new QComboBox(this);
layout->addWidget(select);
layout->setAlignment(select, Qt::AlignRight);

Result of that above code

Upvotes: 2

Related Questions