How do you port QUrl addQueryItem to Qt5's QUrlQuery?
问题 In Qt 4, the following code using QUrl works: QUrl u; foreach (const settings::PostItem & pi, settings.post) u.addQueryItem(pi.name, pi.value); postData = u.encodedQuery(); NOTES : this code is from wkhtmltopdf and postData is a QByteArray. However, Qt 5 does not have the addQueryItem() function anymore. How do you port this code? 回答1: In order to ensure compatibility with Qt 4, add the following lines at the top of your file: #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) # include <QUrlQuery>