编译Qt的Demo

在编译Qt的demo程序时,有时会遇到一个错误提示,无法找到demo_shared.lib。遇到这个链接错误,说明当前编译的QtDemo程序依赖demo_shared.lib这个lib。Qt在编写这些Demo时把部分公用的代码写到了shared项目中,需要先构建该项目生成所需的lib文件。

在构建shared项目时又遇到无法打开qpixmapdata_p.h头文件的错误提示,跳转到错误位置发现,跳转到的文件名就是qpixmapdata_p.h但是里面只写了条include语句,指向所需的qpixmapdata_p.h文件的位置在"../../../src/gui/image/qpixmapdata_p.h"。在SDK安装目录下搜索无果,而且看到“src”目录,猜测这个文件很有可能在Qt的源码里面。QtSDK里是没有src文件夹的,所幸我下载了Qt的源码,果然在src文件夹里面找到了所需文件,修改之前提到的include语句,这样shared项目构建成功,以后所有需要用到该lib的Demo就能编译使用了。

下面是qpixmapdata_p.h文件内容

/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是一个使用QT框架实现DES加解密的示例代码: ```cpp #include <QtCore/QCoreApplication> #include <QDebug> #include <openssl/des.h> #include <string> // DES加密 std::string desEncrypt(const std::string& message, const std::string& key) { DES_cblock desKey; DES_key_schedule keySchedule; // 设置密钥 memcpy(desKey, key.c_str(), 8); DES_set_key_unchecked(&desKey, &keySchedule); // 加密 std::string encryptedMessage(message); DES_ecb_encrypt((DES_cblock*)encryptedMessage.data(), (DES_cblock*)encryptedMessage.data(), &keySchedule, DES_ENCRYPT); return encryptedMessage; } // DES解密 std::string desDecrypt(const std::string& ciphertext, const std::string& key) { DES_cblock desKey; DES_key_schedule keySchedule; // 设置密钥 memcpy(desKey, key.c_str(), 8); DES_set_key_unchecked(&desKey, &keySchedule); // 解密 std::string decryptedMessage(ciphertext); DES_ecb_encrypt((DES_cblock*)decryptedMessage.data(), (DES_cblock*)decryptedMessage.data(), &keySchedule, DES_DECRYPT); return decryptedMessage; } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); std::string message = "Hello, world!"; std::string key = "12345678"; std::string encryptedMessage = desEncrypt(message, key); std::string decryptedMessage = desDecrypt(encryptedMessage, key); qDebug() << "加密后的消息:" << QString::fromStdString(encryptedMessage); qDebug() << "解密后的消息:" << QString::fromStdString(decryptedMessage); return a.exec(); } ``` 以上代码使用了OpenSSL库来实现DES加解密。首先定义了`desEncrypt`和`desDecrypt`函数,分别用于加密和解密操作。然后通过调用这两个函数来进行加解密,并将结果打印输出。 请注意,为了编译此代码,你需要在项目文件(.pro)中添加`LIBS += -lcrypto`以链接OpenSSL库。 希望这个示例对你有帮助!如果你有任何其他问题,请随时提问。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值