#include "mainwindow.h"#include <QApplication>int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();}
#include "mainwindow.h"#include "ui_mainwindow.h"#include "logs.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this);}MainWindow::~MainWindow(){ delete ui;}void MainWindow::plainTextEditEventLogClear(){ qDebug() << "plainTextEditEventLogClear()"; ui->plainTextEdit->clear();}void MainWindow::on_pushButton_clicked(){ logs log; log.clear();}void MainWindow::on_pushButton_2_clicked(){ ui->plainTextEdit->appendPlainText("append text");}
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include <QDebug>namespace Ui {class MainWindow;}class MainWindow : public QMainWindow{ Q_OBJECTpublic: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); void plainTextEditEventLogClear();private slots: void on_pushButton_clicked(); void on_pushButton_2_clicked();private: Ui::MainWindow *ui;};#endif // MAINWINDOW_H
#include "logs.h"#include "mainwindow.h"logs::logs(){}void logs::clear(){ qDebug() << "logs::clear()"; MainWindow mw; mw.plainTextEditEventLogClear();}
#ifndef LOGS_H#define LOGS_Hclass logs{public: logs(); void clear();};#endif // LOGS_H
C++ (Qt) MainWindow mw; mw.ui->label_1->clear();
C++ (Qt)MainWindow::appendMessage(const QString &message);
void MainWindow::plainTextEditEventLogClear(){ qDebug() << "plainTextEditEventLogClear()"; ui->plainTextEdit->clear();}
void logs::clear(){ qDebug() << "logs::clear()"; MainWindow mw; mw.plainTextEditEventLogClear();}
#include "mainwindow.h"#include <QApplication>MainWindow *w = NULL;int main(int argc, char *argv[]){ QApplication a(argc, argv); w = new MainWindow; w->show(); return a.exec();}
C++ (Qt)extern MainWindow * w;
C++ (Qt)w->plainTextEditEventLogClear();