Advertisement
deimos

Untitled

May 20th, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. in your QML add your FilePicker and call the c++ function when a file is selected:
  2. attachedObjects: [
  3. FilePicker {
  4. id: picker
  5. onFileSelected: {
  6. _app.readFileAndPutIntoTextArea(selectedFiles[0], textArea)
  7. }
  8. }
  9. ]
  10.  
  11. TextArea {
  12. id: textArea
  13. }
  14.  
  15.  
  16. the readFileAndPutIntoTextArea looks like:
  17.  
  18. // in ApplicationUI.hpp put this line under public:
  19. // Q_INVOKABLE void readFileAndPutIntoTextArea(QString file, QObject *myTextArea);
  20. #include <bb/cascades/TextArea>
  21. void ApplicationUI::readFileAndPutIntoTextArea(QString file, QObject *myTextArea)
  22. {
  23. bb::cascades::TextArea *obj = qobject_cast<bb::cascades::TextArea *>(myTextArea);
  24. QFile f(file);
  25. if ( f.open(QIODevice::ReadOnly) )
  26. obj->setText(f.readAll());
  27. f.close();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement