Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:41:10+00:00 2026-06-08T13:41:10+00:00

i have a class: Class MyClass { void myMember(); ///code etc private: QFile fileMBox;

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:41:11+00:00Added an answer on June 8, 2026 at 1:41 pm

    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:

    MyClass::MyClass() : fileMBox ("myFile.txt") {}
    

    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:

    MyClass::MyClass() {
        fileMBox.setFileName ("myFile.txt");
    }
    

    Now your function just needs to open it, use it, and close it each time:

    void MyClass::myMember() {
        if (!fileMBox.open (QIODevice::ReadOnly | QIODevice::Text))
            //handle error
    
        //read file and do whatever
    
        fileMBox.close(); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my code organized as following class MyClass { public: typedef void (MyClass::Ptr2func)();
I have some code here private void Run() { MyClass c = new MyClass();
I have the following classes: public class MyClass { public void MyMethod() { try
I have two overloaded member functions with the following signatures: class MyClass { void
I have this class: public MyClass { public void initialize(Collection<String> data) { this.data =
Suppose I have a function defined like this: class Foo() { public: void bar(MyClass*
I have a private variable in my class: BOOL isEnabled; and a method: -(void)
I have class with collection as below public class MyClass:IXmlSerializable { int vesrion; private
I have the following two functions: public class MyClass { public void Save<TObject>(TObject object)
If I have a class as below: class MyClass<T,U> { public void DoSomething(T t)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.