C++ (Qt)void MainWindow::func(QDir dir){ foreach (QFileInfo fileInfo, dir.entryInfoList()) { QApplication::processEvents(); QTextCursor cursor = ui->textEdit->textCursor(); cursor.insertText(fileInfo.absoluteFilePath()); if(fileInfo.isDir() && fileInfo.baseName() != "" && fileInfo.baseName() != "." && fileInfo.baseName() != "..") func(QDir(fileInfo.absoluteFilePath())); }} void MainWindow::on_pushButton_clicked(){ func(some_dir); QMessageBox::information(this, "Title","Конец!");}
C++ (Qt)QApplication::quit()
C++ (Qt)MainWindow::~MainWindow(){ QApplication::quit(); delete ui;} --------------------------------------------------------------------------------void MainWindow::closeEvent(QCloseEvent *event){ Q_UNUSED(event); QApplication::quit(); QMainWindow::closeEvent(event); // если закомментировать тут, все-равно результат отрицательный}
C++ (Qt)QApplication::processEvents();if (funcAbortFlag) return;
C++ (Qt) #include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); w.move(444,55); return a.exec(); }-----------------------------------------------------------------------------------------------------------#ifndef MAINWINDOW_H#define MAINWINDOW_H #include <QtWidgets>#include <QWidget>#include <QMessageBox>#include <QTextEdit>#include <QPushButton>#include <QDir>#include <QTextCursor>#include <QVBoxLayout>#include <QApplication> class MainWindow : public QWidget{ Q_OBJECT public: explicit MainWindow(QWidget *parent = 0) : QWidget(parent) { lay->addWidget(pushButton); lay->addWidget(textEdit); setLayout(lay); connect(pushButton, &QPushButton::clicked,this, &MainWindow::on_pushButton_clicked); } ~MainWindow(){} QPushButton *pushButton = new QPushButton;QTextEdit *textEdit = new QTextEdit;QVBoxLayout *lay = new QVBoxLayout; void func(QDir dir) { foreach (QFileInfo fileInfo, dir.entryInfoList()) { QApplication::processEvents(); QTextCursor cursor = textEdit->textCursor(); cursor.insertText(fileInfo.absoluteFilePath()); if(fileInfo.isDir() && fileInfo.baseName() != "" && fileInfo.baseName() != "." && fileInfo.baseName() != "..") func(QDir(fileInfo.absoluteFilePath())); } } public slots: void on_pushButton_clicked() { func(QDir("D:/Programing/4.8/chapter41")); QMessageBox::information(this, "Title","Конец!"); } }; #endif // MAINWINDOW_H