change the layout of mainwindow and override the resizeEvent of mainwindow