qt-interest@trolltech.com
[Top] [All Lists]

Re: I don't understand this error

Subject: Re: I don't understand this error
From: Andreas Pakulat
Date: Mon, 27 Feb 2006 15:53:40 +0100
On 27.02.06 14:29:11, Oliver Elphick wrote:
> Here is the code that is failing:
> 
> 235   void VanConnect::upload_copy_started(const QList<QNetworkOperation> l)
> 236   {
> 237     QNetworkOperation* op = l.first();
>         ...
>       }
> 
> and the error:
> vanconnect.cpp: In method `void
> VanConnect::upload_copy_started(QList<QNetworkOperation>)':
> vanconnect.cpp:237: passing `const QList<QNetworkOperation>' as `this'
> argument of `class QNetworkOperation *
> QList<QNetworkOperation>::first()' discards qualifiers

What is not understandable in that message? He tells you that using
l.first() discards the const-qualifier from l. This is wrong, because
you get a const list and you're not supposed to change that list,
however QList::first() gives you direct access to a member of the list,
allowing you to change the list. Now the compiler does not allow this,
unless you tell him via a cast that you don't want a const QList, but a
"normal" QList.

> The compiler is claiming the method takes an argument of type
> QList<QNetworkOperation> whereas the actual argument is
> const QList<QNetworkOperation>

No, he's not complaining about your upload_copy_started method, but he's
complaining about the way you use the const QList<> argument.

Andreas

-- 
You will visit the Dung Pits of Glive soon.

--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>