ui->setupUi(this) looks like this is code in the constructor of a widget.

"map" is allocated on the stack, it will be deleted once the constructor ends.
When the widget and the graphics view inside it are painted, there is no item anymore.

Cheers,
_