View Full Version : How to get a Json value from an api and display it in a GUI

4th June 2018, 23:06
Good day,

I'm tring to make a GUI that processes an api requested value. Those values are in Json format.


Let's say I want to get the value of "bid_1" and make a pushbutton and a lable that changes into the value of "bid_1" when clicked.

To make a simple onpushbuttonclicked I use this

void MainWindow::on_pushButton_clicked()
Instead of "hello" I want a String with the value of "bid_1".

As far as I understand I have to use

void MainWindow::on_pushButton_clicked()
QUrl url("https://api.bitmart.com/ticker/BMX_ETH");
QNetworkRequest request(url);
//send request
//read replied data
//interpret replied data as string/Json
But I don't understand and would like to know how to send the request for a specific json value and convert it into a string.

In Python you can just use this.

def funkction():
bid_data = requests.get("https://api.bitmart.com/ticker/BMX_ETH")
return bid_data.json()["bid_1"]

value = float(function())

I'm looking for something simple like that since I'm not that skilled and appreciate any solution with the given example so I can transfer it to my project.

6th June 2018, 15:13
I have not worked with JSON, but this might help http://doc.qt.io/qt-5/json.html