How to open files with QFileDialog or something?
Unsolved
QML and Qt Quick
-
You can write a c++ function that will open the selected file and read its content.
QString CompilerA::open(QString path) { QFile file(path); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream out(&file); out.setCodec("UTF-8"); QString result = out.readAll(); result = result.toUtf8(); file.close(); return resut; }
-
As far as I know there is no direct way to read file content from QML, so some sort of C++ extension is needed, as indicated by @Dannick-Stark.
This StackOverflow answer describes an approach that exposes a "
FileIO
" object to QML from C++.