The code you posted should work ok.
Are you sure it crashes on t1->setText(str) and not later?
Could you show a bit more of the code before and after the lines you posted?