c++qtpointersqscopedpointer

C2248 - No access to private member when passing QScopedPointer to function


I´m getting the following error on this piece of code.

QScopedPointer<NoteEvent> onEvent(new NoteEvent(date, chan, pitch, vel, true));
QScopedPointer<NoteEvent> offEvent(new NoteEvent(date + dur, chan, pitch, vel, false));
Score::noteStream->addNoteEvent(onEvent);
Score::noteStream->addNoteEvent(offEvent);


void NoteStream::addNoteEvent(QScopedPointer<NoteEvent> noteEvent)
{
    noteEvents->push_back(noteEvent);
}

Error: C2248: "QScopedPointer": No access to private member declared in QScopedPointer

Reading through other posts was not helpful.


Solution

  • QScopedPointer doesn't have a public copy constructor. It cannot be passed around by value, nor stored in containers that require its elements to be copyable (which noteEvents might be, depending on how it's declared).