I got the same error and fixed it. Just rename the widget that you added to your mainwindow.ui with name of the pointer that you created. For example, if you defined a pointer as below,
QCustomPlot customPlot;
In this case your widget must be named as "customPlot".