Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- in your QML add your FilePicker and call the c++ function when a file is selected:
- attachedObjects: [
- FilePicker {
- id: picker
- onFileSelected: {
- _app.readFileAndPutIntoTextArea(selectedFiles[0], textArea)
- }
- }
- ]
- TextArea {
- id: textArea
- }
- the readFileAndPutIntoTextArea looks like:
- // in ApplicationUI.hpp put this line under public:
- // Q_INVOKABLE void readFileAndPutIntoTextArea(QString file, QObject *myTextArea);
- #include <bb/cascades/TextArea>
- void ApplicationUI::readFileAndPutIntoTextArea(QString file, QObject *myTextArea)
- {
- bb::cascades::TextArea *obj = qobject_cast<bb::cascades::TextArea *>(myTextArea);
- QFile f(file);
- if ( f.open(QIODevice::ReadOnly) )
- obj->setText(f.readAll());
- f.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement