i have a class:
Class MyClass
{
void myMember();
///code etc
private:
QFile fileMBox;
}
and in the class’ member i try to use:
void MyClass::myMember()
{
fileMBox ("myFile.txt");
}
and i get an error saying: “error: C2064: term does not evaluate to a function taking 1 arguments” but the docs say to use:
QFile file("in.txt");
what am i doing wrong?
thanks
The documentation you brought up is a constructor. It’s called when the object is actually made, not later. You’re acting like the object is a functor, “calling” the object after it’s made.
To utilize the constructor, you can initialize your member with the file name:
However, not having used Qt, I don’t know if that will open it or not. If it does open it, use the below instead:
Now your function just needs to open it, use it, and close it each time: