Always try to use the lowest common denominator.
All objects of the main window are accessible via the main window, thus change the text of a component of the main window inside a function or slot of the main window.

Example

Qt Code:
  1. void MainWindow::slotButtonClicked()
  2. {
  3. int result = doSomething();
  4.  
  5. if (result == 1)
  6. button->setText("New text");
  7. }
  8.  
  9. int MainWindow::doSomething()
  10. {
  11. return something;
  12. }
To copy to clipboard, switch view to plain text mode