.. I dont want to do this in my code taking heap variables for tool bar and tool buttons as I think that makes my program slow.
Why do you think so? Qt Designer (uic) will generate "heap variables" for you actually.
As to your question, please, read docs about Qt Designer & Creating Main Windows in Qt Designer.