The problem is that you declare a local object in the function's scope:

Qt Code:
  1. void DialogForm::on_pbClearLineEdit_clicked()
  2. {
  3. MainWindow m; // <-- this is allocated on the stack and will be deleted at the end of the scope
  4. m.clear(); //
  5. }
To copy to clipboard, switch view to plain text mode 

You should use a signal from the dialog class to inform the MainWindow that the "clear" button was pressed. Declare a signal in your Dialog class and connect it to `MainWindow::clear` slot.