MainWindow *m;//定义全局 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { m = this; ui->setupUi(this); } void MainWindow::appendLog(QString log) { ui->textBrowser->append(log); } void onMessages(void *param2) { //直接用m; m->appendLog("\n" + QString((char *)param2) +"\n"); }
mainwindow.h
public: void appendLog(QString log);