Results 1 to 5 of 5

Thread: combining query lists

  1. #1
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default combining query lists

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Kirovohrad, Ukraine
    Posts
    72
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: combining query lists

    Maybe you should try regexp match?
    Qt Code:
    1. QObjectList *ABClist = BigFrame()->queryList( "Q(Button|LineEdit|ComboBox)" , 0, false, true);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: combining query lists

    Qt Code:
    1. QObjectList *list = BigFrame()->queryList( "QButton", 0, false, false);
    2. list << BigFrame()->queryList( "QLineEdit", 0, false, false);
    3. list << BigFrame()->queryList( "QComboBox", 0, false, false);
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default Re: combining query lists

    Quote Originally Posted by jacek
    Qt Code:
    1. QObjectList *list = BigFrame()->queryList( "QButton", 0, false, false);
    2. list << BigFrame()->queryList( "QLineEdit", 0, false, false);
    3. list << BigFrame()->queryList( "QComboBox", 0, false, false);
    To copy to clipboard, switch view to plain text mode 
    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
    Last edited by jayw710; 10th February 2006 at 19:35.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: combining query lists

    Qt Code:
    1. QObjectList *list = BigFrame()->queryList( "QButton", 0, false, false);
    2. QObjectList *list2 = BigFrame()->queryList( "QLineEdit", 0, false, false);
    3. QObjectList *list3 = BigFrame()->queryList( "QComboBox", 0, false, false);
    4. while(QObject *item = list2->take(0)) list->append(item);
    5. while(QObject *item = list3->take(0)) list->append(item);
    To copy to clipboard, switch view to plain text mode 
    Much slower, but should work in Qt3.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.