PDA

View Full Version : How to Run an URL link when checkBox is checked



soibac35
14th May 2014, 23:20
Hello everyone,
I have looked around the forum as well as Qt documentation (I am still new to Qt) about running a link from qt. Can anyone help me with that. a simple example or some sort would be greatly appropriated.

My goal here is using the Check-box state to activate the url. I was looking at Qurl but not many example are there on the internet. I cant post my code up here since it is a 1500 line of code program (and still expanding) that connect tightly to each other. but basically it is a interface design where i can choose what channel is activate by check the checkbox. if the checkbox is checked, it will run an url that control a piece of hardware over the cloud.
thank in advance

anda_skoa
15th May 2014, 12:53
What do you mean with "run an url"?

Opening it in a browser? See QDesktopServices::openUrl()
Fetching the datafrom the serve? See QNetworkAccessManager::get()

Cheers,
_

soibac35
15th May 2014, 16:24
thanks for reply :)

Those are useful information since eventually im gonna fetch log data to a table in the main windows.
However, is there a way to NOT open the url in the browser ? (Since it is only support in desktop environment). I am looking for something that doesnt have to open the browser since the program will connect to the internet and can be convert-able to android (since running in android is the ultimate goal, for now i just want it in desktop to check if it work)

anda_skoa
16th May 2014, 08:58
It would be really helpful if you stated what you would like to achieve.

"Run an URL link" doesn't mean anything, an URL is usually not an executable, it cannot be run.

So you don't want to show a web page in a browser and you don't want to get the data of said web page.
So what should your program do?

Cheers,
_

soibac35
16th May 2014, 16:45
Sorry if my intention was not clear.

My project will run an IMP electric device where it will sample multiple signals. IMP is a device that help you to control anything over the cloud. So to control which channel will be activated, a address will be given to each state of the pin in this form https://agent.electricimp.com/QtWnl0k5V9OW?=channel_1=1. If you go to your browser and put this address in, the pin will be activated and the whole process of mumbo jumbo will follow .

The project will need an GUI interface. This is where qt comes in. since the user only want to activate some of the channel, I used checkbox to indicate which channel user will use. When the check box is checked, I want that address above to run, and if not, it will do nothing or turn the activated pin off. << this is my main question for now

One more thing is the sample data will be send over the cloud to some storage server. I also have a table where the data will be retrieved from that cloud server in real time if possible. << I am still not sure how to execute this one yet

Those are the 2 things that i want to do at the moment. it would be great if there is some example code or some sort that i can study from :D
Thank you for your help

anda_skoa
17th May 2014, 13:10
So you are interacting with a web service and do not need to show a web page, right?

In this case you are looking for QNetworkAccessManager.
A browser that loads an HTTP URL uses an HTTP "get" request. That operation is QNetworkAccessManager::get()
A browser that submits a web form usually sends a "post" request. That operation is QNetworkAccessManager::post()

Cheers,
_