Created
February 26, 2015 20:17
Revisions
-
ThereExistsX created this gist
Feb 26, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #include "fileio.h" #include <QFile> #include <QTextStream> FileIO::FileIO() { } void FileIO::save(QString text){ QFile file("text.txt"); if(file.open(QIODevice::ReadWrite)){ QTextStream stream(&file); stream << text << endl; } return; } FileIO::~FileIO() { } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #include <QObject> #ifndef FILEIO_H #define FILEIO_H class FileIO : public QObject { Q_OBJECT public: FileIO(); Q_INVOKABLE void save(QString text); ~FileIO(); }; #endif // FILEIO_H This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ #include <QApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #include "fileio.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); engine.rootContext()->setContextProperty("FileIO", new FileIO()); return app.exec(); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 ApplicationWindow { title: qsTr("Hello World") width: 640 height: 480 visible: true TextArea { id: saveMe x: 200 y: 84 } Button { id: button1 x: 283 y: 266 text: qsTr("Save") onClicked: FileIO.save(saveMe.text); } }