#ifndef MYDIALOG_H#define MYDIALOG_H#include <QDialog>namespace Ui {class myDialog;}class myDialog : public QDialog{ Q_OBJECTpublic: explicit myDialog(QWidget *parent = 0); ~myDialog();private: Ui::myDialog *ui;};#endif // MYDIALOG_H
namespace Ui {class myDialog;}
private:Ui::myDialog *ui;
#include "ui_extensionsorter.h"class ExtensionSorter : public QWidget{ Q_OBJECTpublic: ExtensionSorter(QWidget *parent = 0, Qt::WFlags flags = 0); ~ExtensionSorter();private: Ui::ExtensionSorterClass ui;}
#include <QCoreApplication>#include <QDebug>#include <QFile>#include <QFileInfo>#include <QString>void Write(QString fileName){ QFile mFile(fileName); if (!mFile.open(QFile::WriteOnly | QFile::Text)) { qDebug() << "Could not open the file!"; return; } QTextStream out(&mFile); out << "Hello world!"; mFile.flush(); mFile.close();}void Read(QString fileName){ QFile mFile(fileName); if (!mFile.open(QFile::ReadOnly | QFile::Text)) { qDebug() << "Could not open the file!"; return; } QTextStream in(&mFile); QString mText = in.readAll(); qDebug() << mText; mFile.close();}int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); QString mFileName = "/Users/max/myfile.txt"; Write(mFileName); Read(mFileName); return a.exec();}