I have a class that creates a window and a text browser. The text browser is displayed in the window.

I want other classes to be able to print something in that text browser, therefore I have decided to declare it "friend". With this idea, any class can just "include" the window class an be able to print something.

The window class has this function:
Qt Code:
  1. friend void displayMessage(QString message){
  2. textBrowser->append(message);
  3. }
To copy to clipboard, switch view to plain text mode 

Note that textBrowser is public in the window class.

How can I make something like this work ?