PDA

View Full Version : QList of custom type and contains() method



qt_developer
14th March 2014, 13:10
Hi,

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



struct t_myStruct
{
QString myCode;
QtVariantProperty* myQtVariantProperty;
bool operator ==(const t_myStruct &myStr) const
{
return(myStr.myCode == myCode && myStr.myQtVariantProperty == myQtVariantProperty);
}
};

...

t_property propToFind = {code, qtVariantProperty};
if (m_properties.contains(propToFind))
{
// do something
}


Regards.

anda_skoa
14th March 2014, 13:53
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

ChrisW67
14th March 2014, 20:57
A QtVariantProperty and a pointer-to-QtVariantProperty are not the same thing. Something about your code snippets does not gel.