thanks,
i put my code into
MainWindow::MainWindow(QWidget *parent) :

and it worked like i wanted.