QList<MyClass> to const QList<const MyClass>
Hello, How can I cast a QList to a constant QList of constant values without create a new QList (create a constant view of the list)
Example:
Code:
// This not compile
QList<MyClass> a;
// ...
const QList<const MyClass> b = a;
I want to use this for return the list as constant (with constant values too).
Re: QList<MyClass> to const QList<const MyClass>
const QList<const MyClass> b(a); could work.
Re: QList<MyClass> to const QList<const MyClass>
I tested this solution, but does not compile.
Thank you for reply.
Re: QList<MyClass> to const QList<const MyClass>
What is the error message?
Re: QList<MyClass> to const QList<const MyClass>
The error message is:
Code:
error: no matching function for call to 'QList<const MyClass>::QList(QList<MyClass>&)'
note
: candidates are
: QList<T>
::QList(const QList<T>
&) [with T
= const MyClass
]note
: QList<T>
::QList() [with T
= const MyClass
]
In this moment, I am using Qt 4.6 (2010.02.1) with wingw