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 8130797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:51:27+00:00 2026-06-06T08:51:27+00:00

I have two classes, TestA and TestB . TestA extends QObject . I have

  • 0

I have two classes, TestA and TestB. TestA extends QObject. I have it set up with a few Q_PROPERTY‘s like so.

Q_PROPERTY(QString a_string READ getString WRITE setString)
Q_PROPERTY(int a_int READ getInt WRITE setInt)

And, of course, I created the appropriate getters and setters. This class works just fine.

In my second class, TestB, I want to create a Q_PROPERTY that is a TestA, so I did this in testb.h.

Q_PROPERTY(TestA testa READ getTestA)
public:
TestA *getTestA();
private:
TestA mTestA;

And this in testb.cpp.

TestA *TestB::getTestA() {return &mTestA;}

When I try to compile this, I get the following error message.

moc_testb.cpp: In member function 'virtual int TestB::qt_metacall(QMetaObject::Call, int, void**)':
moc_testb.cpp:75: error: no match for 'operator=' in '*(TestA*)_v = TestB::getTestA()'
../qttest/testa.h:7: note: candidates are: TestA& TestA::operator=(const TestA&)

Could someone tell me what I need to do to fix this?

  • 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-06T08:51:28+00:00Added an answer on June 6, 2026 at 8:51 am

    I think the error relates to the READ operation. It is causing the QT function referenced to expect testa to be an object of type TestA, which is returned by the function getTestA. However, getTestA returns a pointer to an object of type TestA instead.

    I think you can resolve the issue by changing the prototype of getTestA to
    TestA getTestA();

    and declaring it as follows:
    TestA TestB::getTestA() {return mTestA;}

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes that I would like to merge into a composite. These
I have two test classes called TT_Common and TT_Container which extends CPPUNIT_NS::TestFixture: class TT_Common
I have two classes like so: public class SentEmailAttachment : ISentEmailAttachment { public SentEmailAttachment();
I have an android test project with two classes: AdapterTestActivity extends ListActivity -> http://pastebin.com/BreRSPj1
I have two classes, Parent and Child. The code for the classes are like
I'd like to have two main classes (or more) with leiningen, and then be
I have two classes generated by LINQ2SQL both from the same table so they
I have two classes.... Parcel and FundParcel...and I'm trying to convert an IEnumerable of
I have two classes that refer to each other, but obviously the compiler complains.
I have two classes; Area and LanguageArea . I use LanguageArea to handle translated

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.