Compile error:
error: no matching member function for call to 'append'
exampleVector.append(display);
~~~~~~~~~~~~~~^~~~~~
.../qvector.h:142:10: note: candidate function not viable: 1st argument ('const QObject ') would lose const qualifier
void append(const T &t);
^
.../qvector.h:143:10: note: candidate function not viable: 1st argument ('const QObject ') would lose const qualifier
void append(T &&t);
^
.../qvector.h:144:17: note: candidate function not viable: no known conversion from 'const QObject ' to 'const QVector<qobject *="">' for 1st argument
inline void append(const QVector<t> &l) { </t></qobject>this += l; }
CPPCheck warning:
style: constVariablePointer - Variable 'display' can be declared as pointer to const
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
CPPCheck 2.14, note, third party source is not available when cppcheck runs
QVector<qobject*> Example()
{
QVector<qobject*> exampleVector;</qobject*></qobject*>
** const QObject display = new QObject(); // const version gives compile error
QObject display = new QObject(); // non-const version gives cppcheck warning**
if(nullptr != display)
{
exampleVector.append(display);
}
return exampleVector;
}
Compile error:
error: no matching member function for call to 'append'
exampleVector.append(display);
~~~~~~~~~~~~~~^~~~~~
.../qvector.h:142:10: note: candidate function not viable: 1st argument ('const QObject ') would lose const qualifier
void append(const T &t);
^
.../qvector.h:143:10: note: candidate function not viable: 1st argument ('const QObject ') would lose const qualifier
void append(T &&t);
^
.../qvector.h:144:17: note: candidate function not viable: no known conversion from 'const QObject ' to 'const QVector<qobject *="">' for 1st argument
inline void append(const QVector<t> &l) { </t></qobject>this += l; }
CPPCheck warning:
style: constVariablePointer - Variable 'display' can be declared as pointer to const
is this issue was fixed ? if yes ,in witch cppcheck version is update??
i use 2.14.1 version and i have the same problem
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/12661
Same type of problem with constParameterPointer.
typedef QList<qobject*> InputList; // some collection in class</qobject*>
void SomeClass::SomeFunction(SomeType* pParameter)
{
Inputs.push_back(pParameter);
}
a call to qt layout -> addWidget() with a const pointer produces compile errors too
cannot initialize a parameter of type 'QWidget ' with an lvalue of type 'const QWidget '
constParameterReference too
operator<<
taking a non-const reference is at least uncommon.