// but i don't know how to get a handle the buttons in window1.cpp since 'ui' is from program.cpp
I was trying to tell you that, make the connections in program.cpp not is window1.cpp, move the connect statements to program class ctor (this is a standard way doing).
In program.cpp you will have handles to buttons, and you also know that wnd1 class has an public slot testx()