Button not aligned to the top in QHboxLayout
-
I have layout with the settings as below
m_pLayout = new QHBoxLayout(this);
m_pLayout->setMargin(0);
m_pLayout->setContentMargin(0,0,0,0);
m_pLayout->setSpacing(0);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
m_pLayout->setAlignment(m_customWidget,Qt::lignTop)
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
-
@thomasjohnaj said in Button not aligned to the top in QHboxLayout:
m_pLayout->setAlignment(m_customWidget,Qt::lignTop)
Just, just in case, please check the return result of this method.
-
@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.