|
Post by bigbass on Sept 19, 2022 0:43:24 GMT 1
Hello QT5 and QML maps demo code (not a full featured app) however the zoom works and you can move to different places on the map outside of the preset view area this is centered in Dover England as the default I wasn't planning to jump into this so soon (hello Alex) because it seemed like a too many things could go wrong and porting several files that are not all bacon compatible had me thinking more than twice to give it a go but I bit the bullet and here it is QMLDOVER.tar.gz (2.14 KB) I may be able to reduce the dependencies or find another way of going about thisshorted code and depends ! but the main focus was getting this ported and working I reduced a lot of files down to this point and learned a few things along the way with qml the original source code link that I ported to bacon stuff.mit.edu/afs/athena/software/texmaker_v5.0.2/qt57/doc/qtlocation/qtlocation-minimal-map-example.htmlUPDATED code dependencies you should install first qtdeclarative5-dev qtlocation5-dev qtpositioning5-dev
qml-module-qtpositioning qml-module-qtlocation had a doubt so tested on a clean box Joe note this is the part that had me stuck Qt complicated the code with a required qrc_qml.cpp engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
I removed a lot of the headache by doing this engine->load(QUrl(QStringLiteral("./main.qml"))) now it is truly dynamic! and easy
|
|
|
Post by bigbass on Sept 19, 2022 3:51:12 GMT 1
now the fun begins sudo apt-get install qml-module-qtquick-controls2
and replace or manually add this to main.qml I get it... this is why they call it quick all is now dynamic to build the widgets with really simple syntax title: "Quit button" Button { x: 10 y: 10 text: "Quit" onClicked: Qt.quit() } main.qml import QtQuick 2.0 import QtQuick.Window 2.0 import QtLocation 5.15 import QtPositioning 5.15 import QtQuick.Controls 2.0
Window { width: 512 height: 512 visible: true
Plugin { id: osmPlugin name: "osm" // specify plugin parameters if necessary // PluginParameter { // name: // value: // } }
Map { anchors.fill: parent plugin: osmPlugin //center: QtPositioning.coordinate(59.91, 10.75) // Oslo center: QtPositioning.coordinate(51.13333 ,1.3) // Dover England zoomLevel: 14 } title: "Quit button" Button { x: 10 y: 10 text: "Quit" onClicked: Qt.quit() } }
|
|
|
Post by alexfish on Sept 19, 2022 12:18:59 GMT 1
compiles and works as intended
some findings
all tile are in one directory IE
/home/pi/.cache/QtLocation/5.8/tiles/osm
zoom 12
osm_100-l-1-12-2062-1368.png
zoom 14
osm_100-l-1-14-8117-5183.png osm_100-l-1-14-8250-5474.png
osm convention example
/dir/14/8117/1368.png as regards to, one can convert existing tiles to the format but need to see if there is a change to this bit :: 'osm_100-l-1-'
other to this
center: QtPositioning.coordinate(51.13333 ,1.3) // Dover England then osm has
osm_gps_map_set_center(map,lat,lon)
in osm have a time out feature to read the gps
examples serial and wifi
timeout = g_timeout_add(2000, GetGPSserial,OSM_GPS_MAP( map)) timeout= g_timeout_add (1000, GetGPSinet,OSM_GPS_MAP(map))
does qt have a timeout
BR Alex
|
|
|
Post by bigbass on Sept 20, 2022 18:03:14 GMT 1
Hello Alex
with just the two line snippet you posted
timeout = g_timeout_add(2000, GetGPSserial,OSM_GPS_MAP( map)) timeout= g_timeout_add (1000, GetGPSinet,OSM_GPS_MAP(map))
translates to this idea
qtimer = new QTimer() '--- widget SIGNAL callback QObject::connect(qtimer, &QTimer::timeout, OSM_SOMETHING) qtimer->start(2000)
not knowing the whole code the idea would be sort of this giving the complete demo of using a time out loop in QT and change it to return what you need
I did this with no widget dependencies to keep it short
*I'll see if I can link this to the c code gps output for a better demo later on maybe it would work?
'---demo using minimum non gui Qtimer bigbass PRAGMA INCLUDE <QtCore/QtCore> <QtCore/QTimer> <QtCore/QDebug> PRAGMA LDFLAGS -lQt5Core PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith
'RPI3 and 4 PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5
'x86_64 'PRAGMA OPTIONS -I/usr/include/x86_64-linux-gnu/qt5
OPTION PARSE FALSE
DEF FN PRINTOUT(x) = qDebug() << (x)
SUB OSM_SOMETHING 'remember we need QStrings in QT!! 'dont forget this is a c++ call too!! PRINT "bacon MAP data" 'PRINTOUT("MAP") END SUB
DECLARE app TYPE QCoreApplication* DECLARE qtimer TYPE QTimer*
app = new QCoreApplication(argc, argv)
qtimer = new QTimer() '--- widget SIGNAL callback QObject::connect(qtimer, &QTimer::timeout, OSM_SOMETHING) qtimer->start(2000)
app->exec()
|
|
|
Post by alexfish on Sept 20, 2022 18:37:53 GMT 1
Hi Joe
Yep, sort of resemble ALARM ? | but have modded the property bit to single shot
hence allows time to ... complete functions
int g_timeout one would use '================================= .. callback() g_source_remove(timeout)
//do until jobs done
timeout = g_timeout_add(time,function,obj(foo)) return true() '================================== Where foo = the map , hence Gui can redraw the map.
the code
'---demo using minimum non gui Qtimer bigbass PRAGMA INCLUDE <QtCore/QtCore> <QtCore/QTimer> <QtCore/QDebug> PRAGMA LDFLAGS -lQt5Core PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith
'RPI3 and 4 PRAGMA OPTIONS -I/usr/include/arm-linux-gnueabihf/qt5
'x86_64 'PRAGMA OPTIONS -I/usr/include/x86_64-linux-gnu/qt5
OPTION PARSE FALSE
DEF FN PRINTOUT(x) = qDebug() << (x)
SUB OSM_SOMETHING
'remember we need QStrings in QT!! 'dont forget this is a c++ call too!! PRINT (const char*)"bacon MAP data" 'PRINTOUT("MAP") qtimer->start(1000) END SUB
DECLARE app TYPE QCoreApplication* DECLARE qtimer TYPE QTimer*
app = new QCoreApplication(argc, argv)
qtimer = new QTimer() '--- widget SIGNAL callback QObject::connect(qtimer, &QTimer::timeout, OSM_SOMETHING) qtimer->setSingleShot(TRUE) qtimer->start(1000)
app->exec()
BR Alex
|
|
|
Post by bigbass on Sept 22, 2022 18:25:00 GMT 1
Hello Alex I modified the gps bacon code to compile for c++ sourceforge.net/p/bacon-qt5/wiki/gps_from_localhost_c%2B%2B/and tested it to be working well another way would be getting the values as a prestep (central location one time) here are two one shot gps demos one in c and one in c++ no widgets or other deps gpsone.bac PRAGMA INCLUDE <gps.h> <math.h> PRAGMA LDFLAGS -Wall -pedantic -pthread -lgps PRAGMA COMPILER gcc PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith PRAGMA OPTIONS -Wno-deprecated -Wno-writable-strings
OPTION PARSE FALSE
'#GPS CODE--------------------------------------------------------------
CONST MODE_STR_NUM = 4
'add 6 zeros automatically to the seconds you want to wait 'dev is device or data the ADDRESS is handled in the macro to keep it easy
DEF FN GPSOPEN(ip,port,dev) = gps_open(ip, port, &dev) DEF FN STREAM(dev,op) = (void) gps_stream(&dev, op, NULL) DEF FN WAITFOR(dev,timesec) = gps_waiting(&dev, timesec * 1000000) DEF FN GPSREAD(dev) = gps_read(&dev, NULL, 0) DEF FN GPSCLOSE(dev) = (void)gps_close(&dev)
DECLARE mode_str[MODE_STR_NUM]= { \ "n/a", \ "None", \ "2D", \ "3D" \ } TYPE static char *
struct gps_data_t gps_data
'#GPS CODE--------------------------------------------------------------
'oneshot one line of gps data no timeouts counter = 0
' ip ,port ,device or data IF (0 ISNOT GPSOPEN("localhost", "2947", gps_data)) THEN EPRINT "Open error. Bye, bye check if you got gps running " END END IF
STREAM(gps_data,WATCH_ENABLE | WATCH_JSON)
'wait for 5 seconds but it is really a onshot with a wait on signal WHILE (WAITFOR(gps_data,2)) AND counter < 1 IF (-1 == GPSREAD(gps_data)) THEN EPRINT "Read error. Bye, bye" BREAK END IF
IF (MODE_SET ISNOT (MODE_SET & gps_data.set)) THEN 'did not even get mode, nothing to see here CONTINUE END IF
IF (0 > gps_data.fix.mode OR \ MODE_STR_NUM <= gps_data.fix.mode) THEN gps_data.fix.mode = 0 END IF
PRINT "Fix mode: ", mode_str[gps_data.fix.mode], \ "Time: ", gps_data.fix.mode FORMAT "%s %s %s %d"
IF (TIME_SET == (TIME_SET & gps_data.set)) THEN ' not 32 bit safe
PRINT gps_data.fix.time.tv_sec, \ gps_data.fix.time.tv_nsec FORMAT "%ld.%09ld "
ELSE PRINT "n/a " END IF
IF (isfinite(gps_data.fix.latitude) && \ isfinite(gps_data.fix.longitude)) THEN 'Display data from the GPS receiver if valid. PRINT gps_data.fix.latitude, gps_data.fix.longitude \ FORMAT "Lat %.6f Lon %.6f\n" ELSE PRINT "Lat n/a Lon n/a\n" END IF 'set for one shot of the gps data read INCR counter WEND ' When you are done... STREAM(gps_data,WATCH_DISABLE) GPSCLOSE(gps_data)
gpsonec++.bac PRAGMA INCLUDE <string.h> <stdio.h> <libgpsmm.h> <math.h> <iostream> <sstream> PRAGMA LDFLAGS -std=c++17 -Wall -pedantic -pthread -lgps PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith PRAGMA OPTIONS -Wno-deprecated -Wno-writable-strings
OPTION PARSE FALSE
'#GPS CODE--------------------------------------------------------------
CONST MODE_STR_NUM = 4
'add 6 zeros automatically to the seconds you want to wait 'dev is device or data the ADDRESS is handled in the macro to keep it easy
DEF FN GPSOPEN(ip,port,dev) = gps_open(ip, port, &dev) DEF FN STREAM(dev,op) = (void) gps_stream(&dev, op, NULL) DEF FN WAITFOR(dev,timesec) = gps_waiting(&dev, timesec * 1000000) DEF FN GPSREAD(dev) = gps_read(&dev, NULL, 0) DEF FN GPSCLOSE(dev) = (void)gps_close(&dev)
DECLARE mode_str[MODE_STR_NUM]= { \ "n/a", \ "None", \ "2D", \ "3D" \ } TYPE static char *
struct gps_data_t gps_data
'#GPS CODE--------------------------------------------------------------
'oneshot one line of gps data counter = 0
' ip ,port ,device or data IF (0 ISNOT GPSOPEN("localhost", "2947", gps_data)) THEN EPRINT "Open error. Bye, bye check if you got gps running " END END IF
STREAM(gps_data,WATCH_ENABLE | WATCH_JSON)
'wait for 5 seconds but it is really a onshot with a wait on signal WHILE (WAITFOR(gps_data,2)) AND counter < 1 IF (-1 == GPSREAD(gps_data)) THEN EPRINT "Read error. Bye, bye" BREAK END IF
IF (MODE_SET ISNOT (MODE_SET & gps_data.set)) THEN 'did not even get mode, nothing to see here CONTINUE END IF
IF (0 > gps_data.fix.mode OR \ MODE_STR_NUM <= gps_data.fix.mode) THEN gps_data.fix.mode = 0 END IF
PRINT "Fix mode: ", mode_str[gps_data.fix.mode], \ "Time: ", gps_data.fix.mode FORMAT "%s %s %s %d"
IF (TIME_SET == (TIME_SET & gps_data.set)) THEN ' not 32 bit safe
PRINT gps_data.fix.time.tv_sec, \ gps_data.fix.time.tv_nsec FORMAT "%ld.%09ld "
ELSE PRINT "n/a " END IF
IF (isfinite(gps_data.fix.latitude) && \ isfinite(gps_data.fix.longitude)) THEN 'Display data from the GPS receiver if valid. PRINT gps_data.fix.latitude, gps_data.fix.longitude \ FORMAT "Lat %.6f Lon %.6f\n" ELSE PRINT "Lat n/a Lon n/a\n" END IF 'set for one shot of the gps data read INCR counter WEND ' When you are done... STREAM(gps_data,WATCH_DISABLE) GPSCLOSE(gps_data)
|
|
|
Post by alexfish on Sept 22, 2022 20:26:23 GMT 1
Hi Joe
will look at those bits in detail + need to put which ever into a function.
in first step I get a segfault on GPSCLOSE(gps_data)
the code just tested
PRAGMA INCLUDE <gps.h> <math.h> PRAGMA LDFLAGS -Wall -pedantic -pthread -lgps PRAGMA COMPILER gcc PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith PRAGMA OPTIONS -Wno-deprecated -Wno-writable-strings
OPTION PARSE FALSE
'#GPS CODE--------------------------------------------------------------
CONST MODE_STR_NUM = 4
'add 6 zeros automatically to the seconds you want to wait 'dev is device or data the ADDRESS is handled in the macro to keep it easy
DEF FN GPSOPEN(ip,port,dev) = gps_open(ip, port, &dev) DEF FN STREAM(dev,op) = (void) gps_stream(&dev, op, NULL) DEF FN WAITFOR(dev,timesec) = gps_waiting(&dev, timesec * 1000000) DEF FN GPSREAD(dev) = gps_read(&dev, NULL, 0) DEF FN GPSCLOSE(dev) = (void)gps_close(&dev)
DECLARE mode_str[MODE_STR_NUM]= { \ "n/a", \ "None", \ "2D", \ "3D" \ } TYPE static char *
struct gps_data_t gps_data
'#GPS CODE--------------------------------------------------------------
'oneshot one line of gps data no timeouts counter = 0
' ip ,port ,device or data IF (0 ISNOT GPSOPEN("localhost", "2947", gps_data)) THEN EPRINT "Open error. Bye, bye check if you got gps running " END END IF
STREAM(gps_data,WATCH_ENABLE | WATCH_JSON)
'wait for 5 seconds but it is really a onshot with a wait on signal WHILE (WAITFOR(gps_data,2)) AND counter < 1 IF (-1 == GPSREAD(gps_data)) THEN EPRINT "Read error. Bye, bye" BREAK END IF
IF (MODE_SET ISNOT (MODE_SET & gps_data.set)) THEN 'did not even get mode, nothing to see here CONTINUE END IF
IF (0 > gps_data.fix.mode OR \ MODE_STR_NUM <= gps_data.fix.mode) THEN gps_data.fix.mode = 0 END IF
PRINT "Fix mode: ", mode_str[gps_data.fix.mode], \ "Time: ", gps_data.fix.mode FORMAT "%s %s %s %d"
IF (TIME_SET == (TIME_SET & gps_data.set)) THEN ' not 32 bit safe
PRINT gps_data.fix.time.tv_sec, \ gps_data.fix.time.tv_nsec FORMAT "%ld.%09ld "
ELSE PRINT "n/a " END IF
IF (isfinite(gps_data.fix.latitude) && \ isfinite(gps_data.fix.longitude)) THEN 'Display data from the GPS receiver if valid. PRINT gps_data.fix.latitude, gps_data.fix.longitude \ FORMAT "Lat %.6f Lon %.6f\n" STREAM(gps_data,WATCH_DISABLE) ' getting segfault here ' GPSCLOSE(gps_data) 'here would need to return true ELSE STREAM(gps_data,WATCH_DISABLE) PRINT "Lat n/a Lon n/a\n" END IF 'set for one shot of the gps data read INCR counter WEND ' When you are done...
' will see if can implement with maps , will post that in archive so you look at at the bits , + 'if it works' or 'have a problem' hopeful tomorrow,
and yes the gps data lat and long are working
BR Alex
|
|
|
Post by alexfish on Sept 23, 2022 20:20:40 GMT 1
Hi Joe Did not get home early. Just Started Hacking the header file 'trying to resolve this bit DECLARE mode_str[MODE_STR_NUM]= { \ "n/a", \ "None", \ "2D", \ "3D" \ } TYPE static char *
anyway whilst trying to locate the header file I came across libgpsmm. Global Positioning System - Qt wrapper for libgps (development)
The gpsd service daemon can monitor one or more GPS devices connected to a host computer, making all data on the location and movements of the sensors available to be queried on TCP port 2947.
This package provides the development file for libQgpsmm, the Qt version of libgpsmm. It contains pkgconfig and qmake bits to build with the library. link to gpsd.gitlab.io/gpsd/index.htmlmaybe home and dry with this one. Will not proceed with a Hack-a-day SCRAP THAT .. did not notice the code . if that oneshot is same link then looks like the browser cache had not updated. gcc- Now I see it. G++ But Header has PRAGMA COMPILER clang++ PRAGMA LDFLAGS -std=c++17 -Wall -pedantic -pthread -lgps Hence will do the includes , with the necessary FUNCTION And Report back BR Alex
|
|
|
Post by alexfish on Sept 23, 2022 22:31:29 GMT 1
Hi Joe Have not got far with this one Position Change in theory, reading qt docs , adding or possible change something could be possible RE example code import QtQuick 2.0 import QtPositioning 5.5 import QtLocation 5.6
PositionSource { id: positionSource }
Map { id: map property MapCircle circle
Component.onCompleted: { circle = Qt.createQmlObject('import QtLocation 5.3; MapCircle {}', page) circle.center = positionSource.position.coordinate circle.radius = 5000.0 circle.color = 'green' circle.border.width = 3 map.addMapItem(circle) } } FROM HEREhave not struck gold as of yet , need to digest and understand the names and ids BR Alex
|
|
|
Post by bigbass on Sept 24, 2022 4:26:06 GMT 1
Hello Alex here is a working Dynamic QML map it is all the parts together and generated a new map depending where you live I added the c++ gps code and a callback and used bacon to generate the new file for the map in real time QML_DYNAMIC.tar.gz (3.03 KB) I have a c code version will post it also tomorrow its late Joe P.S I'll look at the circle code qml a bit odd but at least sort of readable repeating in your head KEY:VALUE
|
|
|
Post by alexfish on Sept 24, 2022 14:49:31 GMT 1
Hi Joe
that works :
and a bit of progress
here have Map : mapview
anchors.fill: parent plugin: osmPlugin //center: QtPositioning.coordinate(59.91, 10.75) // Oslo //center: QtPositioning.coordinate(51.13333 ,1.3) // Dover England center: QtPositioning.coordinate(59.91, 10.75) // Oslo zoomLevel: 14
// enable jest gesture.enabled: true // blagh blare
and can change the in a function callback ID related coords with say
mapview.center = QtPositioning.coordinate(51.13333 ,1.3);
now the map moves from oslo to dover:
looking at the the read gps function this needs to be in the qml code:: any ideas; suppose read file : blagh or can the the read port 2947 be implemented in qml code ?
have not tested
BR Alex
|
|
|
Post by bigbass on Sept 24, 2022 15:43:52 GMT 1
Hello Alex
here is a brief but good report what is happening will add more details later
step 1 the gps code is reading from localhost on port 2947 already and here I convert the C++ numerical data into a baconized string
LATITUDE = gps_data.fix.latitude LONGITUDE = gps_data.fix.longitude latitude$ = STR$(LATITUDE) longitude$ = STR$(LONGITUDE)
step 2 in the callback SUB OSM_SOMETHING I swap out or REPLACE latitude$ and longitude$ with those dummy values hard coded in qml.main and generate the new dynamic main2.qml (this could be done with javascript and qml but I saved you from doing that)
and did it in bacon
array$ = REPLACE$(array$, "gps_data_fix_latitude", latitude$) result$ = REPLACE$(array$, "gps_data_fix_longitude", longitude$)
----------------------------------------------------------------
step 3 main.qml this is a dummy file or a place holder that gets "read only" then changed to a new file written called main2.qml which has the real gps cords.
----------------------------------------------------------- //center: QtPositioning.coordinate(59.91, 10.75) // Oslo //center: QtPositioning.coordinate(51.13333 ,1.3) // Dover England center: QtPositioning.coordinate(gps_data_fix_latitude ,gps_data_fix_longitude) // DYNAMIC placeholder -----------------------------------------------------------
hope it could be useful Joe
|
|
|
Post by alexfish on Sept 24, 2022 17:25:54 GMT 1
Hi Joe
I understand,
what I was doing is separate to that code. a cut down of where I am at with regards events RE Mouse. and getting the map coords to change the gps position the bit
import QtQuick 2.0 import QtQuick.Window 2.0 import QtLocation 5.15 import QtPositioning 5.15
Window { width: 512 height: 512 visible: true
Plugin { id: osmPlugin name: "osm" // specify plugin parameters if necessary // PluginParameter { // name: // value: // } }
Map { id:mapview anchors.fill: parent plugin: osmPlugin center: QtPositioning.coordinate(59.91, 10.75) // Oslo zoomLevel: 14 }
MouseArea { id: mouseArea property variant lastCoordinate anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton // a callback onPressAndHold:{
mapview.center = QtPositioning.coordinate(51.13333 ,1.3); // dover } } }
so as to . can use your code to get the initial gps position
but say if we are on the move then need some method to read the data within the QML code thus if so the can change the map to IE ID mapview
mapview.center = QtPositioning.coordinate(51.13333 ,1.3);
BR Alex
|
|
|
Post by alexfish on Sept 24, 2022 17:41:35 GMT 1
Hi Joe on reflection as far as qml code and osm plugin , possible off the beaten track,as far as Baconising also did not understand that qml is javascript based , mm ,lest said. however feel if can get read 'function on the go' could be a hit in this area , since never seen a demo that can do this nor do i know how to get a read file in jscript... then i start to read stuff like HEREADDED convert string to float : this works in qml var string = "10.745"; var lat = parseFloat(string); console.log("lat") console.log(lat); // float and in the function Above becomes var lat = parseFloat("51.13333") var lon = parseFloat("1.3")
mapview.center = QtPositioning.coordinate(lat,lon); Hi Presto the code import QtQuick 2.0 import QtQuick.Window 2.0 import QtLocation 5.15 import QtPositioning 5.15
Window { width: 512 height: 512 visible: true
Plugin { id: osmPlugin name: "osm" }
Map { id:mapview anchors.fill: parent plugin: osmPlugin center: QtPositioning.coordinate(59.91, 10.75) // Oslo zoomLevel: 14 }
MouseArea { id: mouseArea property variant lastCoordinate anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressAndHold:{
var lat = parseFloat("51.13333"); var lon = parseFloat("1.3");
mapview.center = QtPositioning.coordinate(lat,lon); var coordinate = mapview.toCoordinate(Qt.point(mouse.x,mouse.y));
console.log(coordinate);
} } }
BR Alex
|
|
|
Post by alexfish on Sept 24, 2022 19:02:50 GMT 1
final test on coords mouse x & y
import QtQuick 2.0 import QtQuick.Window 2.0 import QtLocation 5.15 import QtPositioning 5.15
Window { width: 512 height: 512 visible: true
Plugin { id: osmPlugin name: "osm" }
Map { id:mapview anchors.fill: parent plugin: osmPlugin center: QtPositioning.coordinate(59.91, 10.75) // Oslo zoomLevel: 14 }
MouseArea { id: mouseArea property variant lastCoordinate anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton
onPressAndHold:{
var lat = parseFloat("51.13333"); var lon = parseFloat("1.3");
mapview.center = QtPositioning.coordinate(lat,lon); var coordinate = mapview.toCoordinate(Qt.point(mouse.x,mouse.y)); // test mouse.x & y mapview.center = coordinate; console.log(coordinate);
} } }
read file example
var xhr = new XMLHttpRequest; xhr.open("GET", "/home/pi/cairotest.c"); xhr.onreadystatechange = function() { if (xhr.readyState == XMLHttpRequest.DONE) { var response = xhr.responseText; console.log(response); // use file contents as required } }; xhr.send();
get a warning about this api function :: maybe removed ?
however can test by changing the GET, "path/to/myfile"
also can split the file
var xhr = new XMLHttpRequest; xhr.open("GET", "/home/pi/cairotest.c"); xhr.onreadystatechange = function() { if (xhr.readyState == XMLHttpRequest.DONE) { var response = xhr.responseText.split(' '); console.log(response[0]); console.log(response[1]); // use file contents as required } }; xhr.send();
To Suppress the readfile in main.qml
add this to QT code
qputenv("QML_XHR_ALLOW_FILE_READ", QByteArray("1"))
BR Alex
|
|