Is there any particular reason why you are using QtUiTools? This is a very nonstandard approach. Apart that your code looks ok (however a bit unorthodox). What do you mean by that it doesn't work?