I don't think that there is an example for your specific need, and even if it is it won't help you that much - because you don't learn that much when you copy/paste code from an example - so i suggest you create a simple project and if you don't succeed in making it work you can post it here and we will help you understand what have you done wrong.
My guess right now is that you put Write2 function in a different class than the class that has the user interface (and the ui pointer) - this is just a guess, so you need to show us more code and tell the errors for us to help you further - another solution might be to pass an extra QString parameter to the function, so that you won't need the ui->textedit there, something like:
//...rest of your code
//
stream << textToWrite;
}
void Write2(QString Filename2, QString textToWrite){
//...rest of your code
//
stream << textToWrite;
}
To copy to clipboard, switch view to plain text mode
And you call that function from the slot connected with the clicked signal of your button and pass the text too.
Bookmarks