Use QWeakPointer instead of QPointer.