update build script for mac to be more reliable and update mainwindow.cpp to support new version of Qt