Question: hi all i want to update ui from a non member function. Any help other than passing 'this' pointer as my non member is a callback from library.

Below is my code :

mainwindow.cpp

```
static void callback(QString result) 
{
ui->textBrowser->append(result);
}

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_pushButton_clicked()
{
int a=1,b=2;
QLibrary myLib("myaddlib");
myLib.load();
add = (myadd)myLib.resolve("add_function");
add(callback, a, b);
}

```

So all I need is I should be able to append data to UI from my non member callback. Please help me.

EDIT: i am not permitted to modify my callback

EDIT based on comment: `callback` will be called in a different thread, so calling a widget method from there gives error `'cannot send events to objects owned by a different thread'`

Answer: 
None of the things worked for me which were mentioned here. 
Solved it by creating a dummy Qobject which has a public function to send signal to mainwindow. Create an instance of this dummy qobject and call the public function inside my callback.

PS: I have a limitation not to modify my callback hence the above solution.
You can try to find the main window using `QApplication::topLevelWidgets()`.

Once you have found the main window, use `mainWindow->findChild<QTextBrowser*>()` to find the browser widget and then modify its content as you need.

EDIT:  

example: 

```
Q_ASSERT(QApplication::topLevelWidgets() == 1);
QWidget* mainWindow = QApplication::topLevelWidgets().first();
QTextEditor* editor = mainWindow->findChild<QTextBrowser*>();
Q_ASSERT(editor != NULL);
editor->append(QLatin1String("abc"));

```