0
PrimitivePartsWrapperをQObjectのサブクラス(Q_OBJECTマクロを含む)にした後、このエラーを揺らすように見えません。QObjectはmocファイルを作成しますが、まだvtableエラーが発生しています
私はqmakeを実行しており、moc_primitive.cppはmakefileに含まれています。それはQtクリエイターでのみ起こるようです。私がコマンドラインでmakeを実行すると、プログラムはコンパイルされますが、埋め込まれたpythonで、PrimitivePartsクラスが見つからないというエラーが発生します。これは無関係かもしれません。 QtCreatorのエラーは、primitive.oではなくregister.oと何か関係がありますか?またはmoc_primitive.o?
primitive.h:
#ifndef PRIMITIVE_H
#define PRIMITIVE_H
#include "util.h"
class PrimitiveParts {
public:
QVector<Point3> points;
QVector<QList<int> > faces;
};
class PrimitivePartsWrapper : public QObject
{
Q_OBJECT
public slots:
PrimitiveParts* new_PrimitiveParts();
};
namespace primitive {
PrimitiveParts cubePrimitive(float width, float height, float depth);
};
#endif // PRIMITIVE_H
primitive.cpp:
#include "primitive.h"
PrimitiveParts* PrimitivePartsWrapper::new_PrimitiveParts()
{
return new PrimitiveParts();
}
namespace primitive {
PrimitiveParts cubePrimitive(float width, float height, float depth)
{
float hx = width/2;
float hy = height/2;
float hz = depth/2;
// create the vertices
Point3 p0(hx,hy,hz);
Point3 p1(hx,hy,-hz);
Point3 p2(-hx,hy,-hz);
Point3 p3(-hx,hy,hz);
Point3 p4(hx,-hy,hz);
Point3 p5(hx,-hy,-hz);
Point3 p6(-hx,-hy,-hz);
Point3 p7(-hx,-hy,hz);
QList<int> f0 = QList<int>() << 0 << 1 << 2 << 3;
QList<int> f1 = QList<int>() << 4 << 5 << 1 << 0;
QList<int> f2 = QList<int>() << 6 << 2 << 1 << 5;
QList<int> f3 = QList<int>() << 7 << 3 << 2 << 6;
QList<int> f4 = QList<int>() << 7 << 4 << 0 << 3;
QList<int> f5 = QList<int>() << 4 << 7 << 6 << 5;
struct PrimitiveParts parts;
parts.points = QVector<Point3>() << p0 << p1 << p2 << p3 << p4 << p5 << p6 << p7;
parts.faces = QVector<QList<int> >() << f0 << f1 << f2 << f3 << f4 << f5;
return parts;
}
};
何千もの行があるため、すべてのコードを提供することはできません。私はすべてをクリーニングし、qmakeを実行して、すべてを再構築しようとしました。 – voodoogiant
私は何とかあなたのコードをコンパイルしようとしましたが、それはOKと思われます。このエラーは通常、実装されていない仮想関数があることを意味します。あなたはすでにコンストラクタとデストラクタを実装しようとしましたか? –