Qt moc calls the "undefined link to:" error

I am working on a simple widget widget in Qt (all of them belong to the same class). In the header file, I defined

private:
QPointF translateToCanvas (QPointF input);

and in the CPP file I defined

QPointF translateToCanvas (QPointF input) {
    return input - QPointF(CANVAS_MARGIN_X, CANVAS_MARGIN_Y);
}

Elsewhere in the code, I call it

QPointF newPoint = translateToCanvas(anotherPoint);

Whenever I compile, it gives me the error "undefined reference to" MyClass :: translateToCanvas (QPointF) ", and this happens inside the moc generating material, and not actually my literal.

What could be causing this error in Qt? (I am using Qt Creator with Qt 4.5.)

+3
source share
1 answer

This has nothing to do with Qt.

QPointF translateToCanvas (QPointF input) {
    return input - QPointF(CANVAS_MARGIN_X, CANVAS_MARGIN_Y);
}

translateToCanvas, , , , .

QPointF MyClass::translateToCanvas (QPointF input) {
     return input - QPointF(CANVAS_MARGIN_X, CANVAS_MARGIN_Y);
}
+9

Source: https://habr.com/ru/post/1712961/


All Articles