Error occurs when I am ready to pass a function in MyInterface

Asked By 30 points N/A Posted on -


Hello experts,

I have MyInterface with 2 classes A and B, which is implementing MyInterface.

Then I stated 2 objects: 1. MyInterface a = new A (), 2. MyInterface b = new B ().

When I am ready to pass a function – function doSomething(A a){}, the following error occurs:

This is my code:

public interface MyInterface {}

public class A implements MyInterface{}

public class B implements MyInterface{}

public class Tester {

    public static void main(String[] args){
        MyInterface a = new A();
        MyInterface b = new B();

    public static void test(A a){

    public static void test(B b){


My issue is that I am receiving from a few component interfaces which may be in all types of classes. Also, I want to write function for every class.

I need to solve this error. I need your help.

Please give me a solution.


Answered By 0 points N/A #149534

Error occurs when I am ready to pass a function in MyInterface


Hello Annel,

If you are using virtual bases then you would rather don't, for they are not supported by Qobject.

If you have to inherit from Qobject then it is most probably because you want to use the meta-object system that includes the signals, slots, properties and so forward as well as the parent-child relationship. The error you are encountering results from the code that is generated from the Q_OBJECT macro, and that implies that you will have to make use of the meta-object system.

The meta object system has been designed in such a manner that focuses on the fact that there is only one inheritance that comes from the most derived class to the least one, and since it requires to assign at runtime, there is a sequential ID that is meant for each signal, slot, property as well as the enumeration and class info.



Login/Register to Answer

Related Questions