Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Button not aligned to the top in QHboxLayout
thomasjohnaj last edited by
I have layout with the settings as below
m_pLayout = new QHBoxLayout(this);
now I have created a custom widget derived from QAbstarctButton with sizePolicy fixed for both width and height
in SizeHint() method I am setting the fixed size for the widget
Now when I add the widget to the layout i am setting the alignment Top
where m_customWidget is the custom widget .
After setting the alignment to top the widget is not aligned to top. It is set at the centre
What Might be the reason, Am I missing something? please guide
JonB last edited by
Just, just in case, please check the return result of this method.
thomasjohnaj last edited by thomasjohnaj
@JonB It was a mistake from my side, I was using m_pLayout->addWidget( m_customWidget, Qt::AlignTop) instead of m_pLayout->setAlignment(m_customWidget,Qt::AlignTop) ( event though in question I mentioned it ) it worked when I used setAlignment call.
But what is the difference from both the calls? Both have the options to set Alignemnt, but why first one didn't work for me.