Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-53152

Register comparators for std::vector in QVariant

    XMLWordPrintable

Details

    Description

      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> ); does not help

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            jpo38 Jean Porcherot
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes