Find root cause of “cannot access private member declared in class 'QObject'”

前端 未结 2 1315
说谎
说谎 2021-01-24 13:34

I understand why I get a C2248: \'QObject::QObject\' : cannot access private member declared in class \'QObject\' . Qt objects are not copyable, as explained here:<

2条回答
  •  旧巷少年郎
    2021-01-24 14:01

    If you are not explicitly copying your MyObject but you keep getting this error message then something you're using in conjunction with your MyObject is doing the copying on your behalf.

    The most likely culprit would be one of the container classes, e.g. QList, QVector, etc.

    Read the Container class documentation for more information as well as the specific class' documentation of any container you might be using. All containers have requirements of their elements, e.g. Must have default constructor, must be assignable, etc. This is where I think your problem lies.

提交回复
热议问题