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

QVector erase does not accept output from qFind

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.13.2
    • Core: Other
    • None
    • Visual Studio 2019.  Windows 10 x64
    • c946b07d9c2023c56ec3cae3ef8a425d12f8d7df (qt/qtbase/dev)

    Description

       

      replacing qFind with std::find produces the same error.

      replacing  qFind with std::find and replacing QVector with std::vector compilles.

       

      class DirTreeModelItem;
      
      int main(int argc, char *argv[])
      {    
          QVector<DirTreeModelItem *> children_;
          DirTreeModelItem *placeHolderChild_;    
          auto it = qFind(children_.cbegin(), children_.cend(), placeHolderChild_);
          if (it != children_.cend())
          {
              children_.erase(it);
          }
      }
      1>C:\Users\drogers\Documents\Visual Studio 2010\Projects\ImageViewers\Phot\main.cpp(24,27): error C2664: 'DirTreeModelItem **QVector<DirTreeModelItem *>::erase(DirTreeModelItem **)': cannot convert argument 1 from 'InputIterator' to 'DirTreeModelItem **'
      1>        with
      1>        [
      1>            InputIterator=DirTreeModelItem *const *
      1>        ]
      1>C:\Users\drogers\Documents\Visual Studio 2010\Projects\ImageViewers\Phot\main.cpp(24,25): message : Conversion loses qualifiers
      1>C:\Qt\Qt-5.13.2\include\QtCore\qvector.h(238,21): message : see declaration of 'QVector<DirTreeModelItem *>::erase'
      1>C:\Users\drogers\Documents\Visual Studio 2010\Projects\ImageViewers\Phot\main.cpp(21,1): warning C4996: 'qFind': Use std::find
      1>C:\Qt\Qt-5.13.2\include\QtCore\qalgorithms.h(120): message : see declaration of 'qFind'
      1>Done building project "Phot.vcxproj" -- FAILED.
      

      Attachments

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

        Activity

          People

            laknoll Lars Knoll
            doug_rogers Doug Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes