Results 1 to 3 of 3

Thread: QList of custom type and contains() method

  1. #1
    Join Date
    May 2012
    Posts
    99
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question QList of custom type and contains() method

    Hi,

    I've implemented this code to find a certain property in the QList. Is right the code?

    Qt Code:
    1. struct t_myStruct
    2. {
    3. QString myCode;
    4. QtVariantProperty* myQtVariantProperty;
    5. bool operator ==(const t_myStruct &myStr) const
    6. {
    7. return(myStr.myCode == myCode && myStr.myQtVariantProperty == myQtVariantProperty);
    8. }
    9. };
    10.  
    11. ...
    12.  
    13. t_property propToFind = {code, qtVariantProperty};
    14. if (m_properties.contains(propToFind))
    15. {
    16. // do something
    17. }
    To copy to clipboard, switch view to plain text mode 

    Regards.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QList of custom type and contains() method

    If it works, it is the right code.

    Cheers,
    _

    P.S.: assuming that t_myStruct and t_property are in fact the same and just a typo here

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QList of custom type and contains() method

    A QtVariantProperty and a pointer-to-QtVariantProperty are not the same thing. Something about your code snippets does not gel.

Similar Threads

  1. Replies: 5
    Last Post: 27th December 2013, 13:32
  2. QList of variable data type?
    By Phlucious in forum Qt Programming
    Replies: 13
    Last Post: 2nd December 2011, 00:25
  3. Changing the type of QList
    By wagmare in forum Newbie
    Replies: 4
    Last Post: 19th October 2011, 11:59
  4. Mac OSX: QList<(type)>::detach_detach.* coming up unresolved.
    By rickbsgu in forum Installation and Deployment
    Replies: 0
    Last Post: 1st September 2010, 18:27
  5. 'QList' does not name a type
    By Qt Coder in forum Qt Programming
    Replies: 3
    Last Post: 22nd September 2009, 14:28

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.