Access an QHBoxLayout, which name you don't know
Hi,
inside a class I have:And now I want to chance the direction of the QGroupBox, without using hboxLayout!
There is an gb->layout(), but that only return a QLayout, not my hboxLayout, which I need. Is it possible to recive a pointer to the QHBoxLayout hboxLayout, if one does not know its name (in my example 'hboxLayout')?
Thanks
Lykurg
Re: Access an QHBoxLayout, which name you don't know
layout() returns the widget's layout. You have to cast it to another class if you want to have QHBoxLayout instead of QLayout. qobject_cast and/or QMetaObject::className() might come in handy here to know the layout class.
Re: Access an QHBoxLayout, which name you don't know
Code:
qobject_cast<QHBoxLayout
*>
(gb
->layout
())->setDirection
( QBoxLayout::TopToBottom );
works fine.
Thanks a lot, Lykurg.
Re: Access an QHBoxLayout, which name you don't know
Something like this would be better:
Code:
QHBoxLayout *l
= qobject_cast<QHBoxLayout
*>
(gb
->layout
());