Call ui->setupUI(this) before using anything in ui, better call it as first statement in constructor.