You need to have this
private:
void LevelWrite();
in your .h file. Most likely you will just need to add the void LevelWrite() line underneath the already existent private: section of your .h file. And then in your .cpp file you will need to have
void MainWindow::LevelWrite()
Then you should be able to use ui->
within your LevelWrite method. Hopefully this can also help someone else who is running into the same problem.