Qt pixmap实现disabled等状态
QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const;
enum Mode { Normal, Disabled, Active, Selected };
enum State { On, Off };
利用QIcon来实现就行
libcurl图片上传在window和linux下实现
l#libcurl
LIBS += -L"curl/lib/curl" -llibcurl
LIBS += -L"curl/lib/curl" -llibcurld
INCLUDEPATH += curl/include
#~libcurl
ibcurl linux相关方法
#ubuntu libcurl
#apt-get install libcurl4-openssl-dev
#https://blog.csdn.net/u011641885/article/details/46900771
#libcurl
CONFIG(debug,debug|release):INCLUDEPATH += /usr/include
CONFIG(release,debug|release):INCLUDEPATH += /usr/local/libcurl/include
LIBS +=-lcurl
#~libcurl
window 下推荐使用postman工具来调试post、get、上传图片等
post方法:
CURL* curl = curl_easy_init();
if(NULL == curl)
{
curl_easy_setopt(curl, CURLOPT_URL, url.toStdString().c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 3);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3);
res = curl_easy_perform(curl); // 发送
curl_easy_cleanup(curl);// 清空
}
get方法:
CURL* curl = curl_easy_init();
if(NULL == curl)
{
curl_easy_setopt(curl, CURLOPT_URL, url.toStdString().c_str());
curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 3);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3);
res = curl_easy_perform(curl); // 发送
curl_easy_cleanup(curl);// 清空
}
upload image
CURL* curl = curl_easy_init();
if(NULL == curl)
{
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, filekey.toStdString().c_str(),
CURLFORM_FILE, filepath.toStdString().c_str(),
CURLFORM_END);
curl_easy_setopt(hnd, CURLOPT_URL, url.toStdString().c_str());
curl_easy_setopt(hnd, CURLOPT_HTTPPOST, formpost);
ret = curl_easy_perform(hnd);
//~
//free
curl_easy_cleanup(hnd);
curl_formfree(formpost);
}
Openssl::SHA1和QCryptographicHash::Sha1
QCryptographicHash *hash = new QCryptographicHash(QCryptographicHash::Sha1);
hash->addData(prepare_sign);
sigret = hash->result().toHex().data();
QByteArray sigret;
sigret.resize(20);//SHA1:20,SHA256:32
SHA1((unsigned char*)prepare_sign.data(), prepare_sign.length(), (unsigned char*)sigret.data());
sigret = sigret.toHex().toLower();