Strange Error message
-
Hi all
I am getting a strange error message i've never seen before when trying to run the below program.
error message:
in copy constructor 'staff::staff(const staff&)''QObject::QObject(const QObject)' is private within this context
my code:
https://www.dropbox.com/sh/wowwansg38mortr/AAD8o15lr1paOb7SJyUC73RMa?dl=0I understand that private member functions can only be called from the same class but not sure what that means in this instance. Am I calling the copy constructor of staff somewhere I shouldn't be calling it from?
Thanks
Deon
-
Looks like you are passing some object by value. Since copy constructor is disabled. Try passing reference.
-
Hi Dheerendra there was a constructor in the staffList class where I passed a staff object. I fixed that but still no luck. i've gone over everything a few times and don't see any other functions with objects in their parameter list... Is there any way to see where this issue is coming from? When I click on the error message it opens QObject.h which doesn't help much...
-
Just try clean once, run qmake and rebuild. If you still face the issue, drop me the code. I will check and revert quickly.
-
Tried that but still no change...
Thanks for taking a lookmy code:
https://www.dropbox.com/sh/qkujdbs0trjksvq/AADEV3y0xMyQ__WyP6IkzLOha?dl=0
-
Hi,
You can't copy QObject derived class so addToList should have a pointer to staff as parameter
-
Is this code located in a function ?
-
You can't write code freely anywhere in a file in C/C++ It needs to be inside a function/method.
-
Thanks I moved it into a function. now i'm getting an error invalid conversion from int to char* in the following function @QString staff::toString() {
return QString("Name: %1 \n Birth Date: %2 \n Staff Type: %3 \n \n").arg(s_name).arg(s_birthDate.toString('yyyyMMdd').arg(getTypeString()));
}@there's no int in this function though? Could it be the enum s_type? I created a function getTypeString @
staff::getTypeString() {
return property("Type").toString();
}
that's supposed to return a QString... -
The only error I see currently is that you have a misplace arg. You attached your third parameter to the s_birthDate.toString call
-
Nop, that part is fine
-
@
QString("Name: %1 \n Birth Date: %2 \n Staff Type: %3 \n \n")
.arg(s_name) << correct
.arg(s_birthDate.toString('yyyyMMdd').arg(getTypeString() << arg of toString rather than arg for QString()
@