Qt pixmap实现disabled等状态,libcurl图片上传在window和linux下实现,Openssl::SHA1和QCryptographicHash::Sha1

21 篇文章 0 订阅
8 篇文章 0 订阅

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下实现

libcurl window相关库文件

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();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值