PDA

View Full Version : combining query lists



jayw710
9th February 2006, 23:35
Hello,

I have a query list

QObjectList *Alist = BigFrame()->queryList( "QButton" ,0, false, false);
QObjectList *Blist = BigFrame()->queryList( "QLineEdit" ,0, false, false);
QObjectList *Clist = BigFrame()->queryList( "QComboBox" ,0, false, false);

I need to grab all children that are qbuttons, qlineedits or qcomboboxes. Is there a way to combine these 3 lists so that I can loop through the query list only once?

Thanks!

Jay

Cesar
10th February 2006, 00:14
Maybe you should try regexp match?

QObjectList *ABClist = BigFrame()->queryList( "Q(Button|LineEdit|ComboBox)" , 0, false, true);

jacek
10th February 2006, 00:37
QObjectList *list = BigFrame()->queryList( "QButton", 0, false, false);
list << BigFrame()->queryList( "QLineEdit", 0, false, false);
list << BigFrame()->queryList( "QComboBox", 0, false, false);

jayw710
10th February 2006, 19:32
QObjectList *list = BigFrame()->queryList( "QButton", 0, false, false);
list << BigFrame()->queryList( "QLineEdit", 0, false, false);
list << BigFrame()->queryList( "QComboBox", 0, false, false);

You would think this would work great, but "<<" isn't defined for QObjectList. I can't find anything in the documentation that tells me how to do anything other than an initial assignment of a list or appending a single item at a time.

I don't want to do the regexp if I can at all avoid it because that's only for the name as opposed to the object type, which could get flakey. I'm using 3.3.4, so I don't know if this has changed for Qt 4. Any other workarounds someone might think of?

Thanks again,
Jay

wysota
10th February 2006, 21:17
QObjectList *list = BigFrame()->queryList( "QButton", 0, false, false);
QObjectList *list2 = BigFrame()->queryList( "QLineEdit", 0, false, false);
QObjectList *list3 = BigFrame()->queryList( "QComboBox", 0, false, false);
while(QObject *item = list2->take(0)) list->append(item);
while(QObject *item = list3->take(0)) list->append(item);
Much slower, but should work in Qt3.