I added a button inside QHBoxLayout layout and it got aligned in right side.
My intention is to give 1 cm gap on top and right side of the button.
m_clearButton = new QPushButton(widget);
m_clearButton->setText("Clear");
m_clearButton->setMinimumWidth(35);
m_clearButton->setMinimumHeight(10);
m_clearButton->setFocusPolicy(Qt::NoFocus);
QHBoxLayout * mainLyt1 = new QHBoxLayout(this);
mainLyt1->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
mainLyt1->addWidget(m_clearButton,0,Qt::AlignRight);
ANy input is appreciated, Thanks
You can set content margin to that layout. http://doc.qt.io/qt-4.8/qlayout.html#setContentsMargins