Good day,
I'm tring to make a GUI that processes an api requested value. Those values are in Json format.
https://api.bitmart.com/ticker/BMX_ETH
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()
{
ui->label_11->setText("Hello");
}
void MainWindow::on_pushButton_clicked()
{
ui->label_11->setText("Hello");
}
To copy to clipboard, switch view to plain text mode
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
ui
->label
->setText
(QString::number);
}
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
ui->label->setText(QString::number);
}
To copy to clipboard, switch view to plain text mode
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())
def funkction():
bid_data = requests.get("https://api.bitmart.com/ticker/BMX_ETH")
return bid_data.json()["bid_1"]
value = float(function())
To copy to clipboard, switch view to plain text mode
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.
Bookmarks