问题
I have a program that uses a set of files stored in a GitHub project.
I would like to check the latest release version of that GitHub project and download those files if it's newer than local.
Does anyone know how to check release version and download from (using QT C++)?
My program is done in Qt 5 (https://github.com/bq/QssWeb2Board)
回答1:
Checking the commented lib and doing some digging around I found an answer. Here it is the main code. Thanks.
QUrl url("https://api.github.com/repos/" + owner +"/" + project + "/tags");
qInfo() << url.toString();
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QNetworkAccessManager nam;
QNetworkReply * reply = nam.get(request);
timeout=false;
timer->start(5000);
while(!timeout){
qApp->processEvents();
if(reply->isFinished()) break;
}
if(reply->isFinished()){
QByteArray response_data = reply->readAll();
QJsonDocument json = QJsonDocument::fromJson(response_data);
return json[0]["name"].toString();
}else{
return QString("Timeout");
}
来源:https://stackoverflow.com/questions/50540184/c-get-latest-release-of-a-github-project