Results 1 to 3 of 3

Thread: Counting and looping properties

  1. #1
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Thanks
    10
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Counting and looping properties

    hi,
    i have a class with properties and i want to make automatic XML saving of all properties.
    can i loop trough all properties?
    something like this
    Qt Code:
    1. for(quint i=0;i<propertiesCount();i++)
    2. {
    3. saveToXml(properties[i]);
    4. }
    To copy to clipboard, switch view to plain text mode 

    Maybe someone have a solution that i can apply?
    or there is another way, that is commonly used?

    Thank you

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

  3. #3
    Join Date
    May 2008
    Location
    Rijeka, Croatia
    Posts
    85
    Thanks
    10
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Counting and looping properties

    ill try this:
    Qt Code:
    1. const QMetaObject* metaObject = obj->metaObject();
    2. QStringList properties;
    3. for(int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i)
    4. properties << QString::fromLatin1(metaObject->property(i).name());
    To copy to clipboard, switch view to plain text mode 
    thanks

Similar Threads

  1. counting controls in a form with its childs ?
    By hcetiner in forum Qt Programming
    Replies: 1
    Last Post: 6th April 2010, 19:14
  2. Qmessagebox cant stop looping
    By Devoraz in forum Newbie
    Replies: 9
    Last Post: 7th August 2009, 07:34
  3. Counting flags in a bit mask
    By Lykurg in forum General Programming
    Replies: 1
    Last Post: 24th July 2009, 10:53
  4. [QT4] Counting files in a directory (Linux)
    By ucntcme in forum Qt Programming
    Replies: 2
    Last Post: 24th July 2007, 22:59
  5. QtKey looping
    By VireX in forum Newbie
    Replies: 4
    Last Post: 15th February 2007, 20:52

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.