diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 7f842e29a65..8da33e0c4e5 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -488,17 +488,16 @@ QPersistentModelIndex &QPersistentModelIndex::operator=(const QModelIndex &other } /*! - \fn QPersistentModelIndex::operator const QModelIndex&() const + \fn QPersistentModelIndex::operator QModelIndex() const - Cast operator that returns a const QModelIndex&. + Cast operator that returns a QModelIndex. */ -QPersistentModelIndex::operator const QModelIndex&() const +QPersistentModelIndex::operator QModelIndex() const { - static const QModelIndex invalid; if (d) return d->index; - return invalid; + return QModelIndex(); } /*! diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 7479f4b043b..789ed60ce49 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -226,7 +226,7 @@ class Q_CORE_EXPORT QPersistentModelIndex bool operator==(const QModelIndex &other) const; bool operator!=(const QModelIndex &other) const; QPersistentModelIndex &operator=(const QModelIndex &other); - operator const QModelIndex&() const; + operator QModelIndex() const; int row() const; int column() const; void *internalPointer() const;