The first thing I would do is look very hard at the discrepancy in the second parameter of your signal/slot match.
One is QPolygon&
and the other is CustomPolygon*
. My understanding is that these had to match. Even if one were a proper subclass of the other, I don't think you can mix references and pointers like that.
And,regarding your (slightly paraphrased) comment:
My slot has to stay as a pointer because it points to an item that is being deleted from a QGraphicsScene
.
My signal cant be a pointer because there is no conversion from a QPolygonF
to a QPolygonF *
, and I require QPolygonF
to mapToScene
.
I think I understand what you're saying, and there are a couple of issues.
If your slot takes a pointer that will be freed, you have to give it a pointer, and relinquish control of the object behind it (so either start with a dynamically allocated copy you're willing to let go of, or make a dynamically allocated copy from something you don't want to let go of).
And I'm not sure why you think there's no conversion from the object to a pointer to that object. I suppose that's technically true since the class itself doesn't provide a conversion, but this is really part of the base language:
Type thing;
Type *pointerToThing = &thing;
Both those issues should be solvable with something like:
QVector<QPointF> points;
QPolygonF thisIsMyPoly = mapToScene(polygon());
QploygonF *thisIsPolyForFreeing = new QPolygonF(thisIsMyPoly);
emit editPolygon(points, thisIsPolyForFreeing);
Your signal will still have to be changed to use a pointer rather than a reference and, hopefully, that will alleviate the mismatch.
If your pointer is an actual pointer to a QPolygonF
that cannot be copied (because it's the pointer to the actual item being held in the QGraphicsScene
and you therefore need the original pointer to remove it), I think you should just be able to pass that pointer as-is, assuming mapToScene()
is returning a reference to it rather than a copy:
QPolygonF poly = mapToScene(polygon()); // get ref.
emit editPolygon(points, &poly); // pass ref's address.
No such signal
) is because Signal/Slot function signatures should exactly match – Mohammad Kanan