Reputation: 127
I'm trying to use the data from a function that returns a QString in a Const function that uses a Const Char*. The problem is basically the following :
int myObject::listChildProcesses([...]) const {
// getProcessName called from : QString myObject::getProcessName() { [...] }
const char* name = getProcessName().toLocal8Bit();
[...]
}
Which returns :
passing 'const myObject' as 'this' argument of 'QString myObject::getProcessName()' discards qualifiers
So ... I think there is a constness problem here. However, I DO need to keep my constness in listChildProcess. Do you happen to know how I can solve that problem by keeping it ?
Upvotes: 1
Views: 584
Reputation: 54705
It seems that myObject::getProcessName()
doesn't have a const
qualifier, but called for a constant object. So you should make change its signature to QString myObject::getProcessName() const
.
Upvotes: 3