You are calling the UI setup method twice, but more importantly: the second call is made after the explicit widget addition to the "default" UI.
That is not good because then the widget is "cleared" by the second since it will set up the UI based on your UI file again which does not contain the widget as that is added explicitly, so just remove that line.
Therefore, you should be writing this instead:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->gridLayout->addWidget(new QLabel("test"),0,0);
// MainWindow does other stuff
}