PDA

View Full Version : Implicitly move child widgets *on their own.*



tescrin
7th August 2012, 21:32
I have a widget that (for example) wants to move child widgets without moving itself. It'd be grand if this were done without explicitly knowing the child. I.E. the widget A is a container and has a widget B placed into it (making B a child of A.) I wish to have widget B move when A.Event happens.

It looks like in QObject the findChildren would work. I need a list of *all of the children.* So I assume I should pass a regular expression that allows everything; maybe:

//formatted to separate the reg exp for you
WidgetA->findChildren(
QRegExp(
QString([a-zA-Z0-9|_]*)
)
);

I guess I'm looking to verify that this is the correct idea and that the reg-exp is correct;
Thanks for any help!

ChrisW67
8th August 2012, 01:08
If you want all the children of a certain type then you pass nothing to the QObject::findChildren() function. If the object names of the objects you are interested in follow some known pattern then you could use a regular expression: your current expression matches most names.

tescrin
8th August 2012, 17:22
Thanks! I hadn't noticed the <T> in the function to specify type 'til you posted.