Getting Parent Layout in Qt

Posted by Austin on Stack Overflow See other posts from Stack Overflow or by Austin
Published on 2010-03-09T14:06:31Z Indexed on 2010/03/13 8:35 UTC
Read the original article Hit count: 274

Filed under:
|
|
|

Hi, quick question. Is there any way to (easily) retrieve the parent layout of a widget in Qt?

PS: QObject::parent() won't work, for logical reasons.

EDIT: I'm positive the widget has a parent layout, because I added it to a layout earlier in the code. Now, I have many other layouts in the window and while it is possible for me to keep track of them, I just want to know if there is an easy and clean way to get the parent layout.

EDIT2: Sorry, "easy and clean" was probably not the best way of putting. I meant using the Qt API.

EDIT3: I'm adding the widget to the layout like this:

QHBoxLayout* layout = new QHBoxLayout;

layout->addWidget(button);

© Stack Overflow or respective owner

Related posts about qt

Related posts about layouts