Consider this code:
std::vector< std::vector<int> > v;
v.push_back( std::vector<int>( 1, 4 ) );
v.push_back( std::vector<int>( 1, 3 ) );
QComboBox box;
box.addItem( "", QVariant::fromValue<std::vector<int>>( v[0] ) );
box.addItem( "", QVariant::fromValue<std::vector<int>>( v[1] ) );
int pos = box.findData( QVariant::fromValue<std::vector<int>>(v[0]) );
pos
is -1
, when 0
was expected.
Manual search (for i
to box.count()
) is doable and works. As ( box.itemData( 0 ).value< std::vector<int> >() == v[0] )
surprisingly returns true
! But findData
is supposed to work too!
Note: Adding Q_DECLARE_METATYPE( std::vector<int> );
did not help
Edit 2016/05/03: Filled a Qt bug: https://bugreports.qt.io/browse/QTBUG-53152