Android : How to connect to a server from Qt C++ and QML

on Saturday, July 5, 2014


I have a Qt app that works in Desktop and android. When I was developing the app I refereed to some photos by their absolute path on my computer in both C++ and QMl, everything worked just fine.


Now I'm deploying on android, I setup IIS on my computer and I put all the files I want the application to get from my computer on the same folder where IIS starts (the "wwwroot").


A friend of mine gave me some php files to put them in the same directory where IIs starts to allow the connection. I changed the paths to the files on my C++ and Qml codes to connect to the new path through the server. here is an example for the paths before and after:


in C++


before



QString path("E:/project/Server/Labs/");


after



QString path("http://192.168.173.1/Server/Labs/");


in Qml


before



source: 'file:///E:/project/Server/Labs/image.jpg'


after



source: 'http://192.168.173.1/Server/Labs/image.jpg'


Now I'm able to get the files in qml successfully, but not the files in the C++ part. I can't connect to the folders and files in the server through C++.


So is there something I should do in the C++ part?


-Note: On Desktop when I leave the paths in qml to


source: 'http://192.168.173.1/Server/Labs/image.jpg' they don't work and I get these errors



QSslSocket: cannot resolve TLSv1_1_client_method
QSslSocket: cannot resolve TLSv1_2_client_method
QSslSocket: cannot resolve TLSv1_1_server_method
QSslSocket: cannot resolve TLSv1_2_server_method


So I have to change the paths back to source: 'file:///E:/project/Server/Labs/image.jpg' in order to work on desktop.


Thank you.


0 comments:

Post a Comment