Qt中使用Firebird 和 Firebird Embedded
摘要:编译数据库连接插件 拷贝ibase.h,fbclient_ms.lib(改名gds32_ms.lib)等到ibase.pro项目文件夹下 编译完成后,会生成qsqlibase.dll 在Qt中使用 发布 qsqlibase.dll放到sqldrivers目录下 普通服务器版本,需要带上fbclien
阅读全文
posted @
2016-04-21 16:35
淡菊
阅读(786)
推荐(0)
Qt Script
摘要:旧项目运行在Qt4.x上,要加上一个脚本逻辑,只能上Qt Script.(建议新项目使用QJSEngine)QT += script#include int cpp_func(int a, int b){ return a + b;}QScriptValue cpp_func_wrapper(...
阅读全文
posted @
2015-12-26 09:05
淡菊
阅读(1753)
推荐(0)
Qt实现指定线程执行回调
摘要:说明同线程时,直接调用回调(block参数没意义)创建invoker所在的线程,需要有Qt的消息循环(比如UI线程)直接上代码typedef std::function InvokerFunc;class Invoker: public QObject{ Q_OBJECTpublic: ...
阅读全文
posted @
2015-12-10 14:45
淡菊
阅读(1261)
推荐(0)
利用QObject反射实现jsonrpc
摘要:1.jsonrpc请求中的params数组生成签名 static QString signatureFromJsonArray(const QJsonArray &array) { QStringList list; foreach(const QJsonVal...
阅读全文
posted @
2015-10-08 17:00
淡菊
阅读(724)
推荐(0)
std::function赋值的几种方法
摘要:定义: #include std::function myPrintFunction; 函数指针 void directPrint(const QString &msg){ qDebug()} myPrintFunction = directPrint; lambda myPrintFunct...
阅读全文
posted @
2014-06-09 11:01
淡菊
阅读(7521)
推荐(1)
Qt postEvent
摘要:Qt3中可以直接向线程发送消息 QThread::postEventQ4中已不支持为了模拟向线程发送消息,可以通过QObject::moveToThread后,然后再向这个QObject发送消息object = new QObject;object.moveToThread(thread);QCor...
阅读全文
posted @
2014-05-19 14:58
淡菊
阅读(2778)
推荐(0)
Qt由pcm数据生成wav文件
摘要:void AudioGrabber::saveWave(const QString &fileName, const QByteArray &raw, const QAudioFormat &format){ typedef struct{ char riff_fileid[4];//"RIFF" ...
阅读全文
posted @
2014-05-08 14:58
淡菊
阅读(2842)
推荐(0)
Qt websocket协议的实现
摘要:handshake(握手) client请求: GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBu...
阅读全文
posted @
2014-04-26 16:07
淡菊
阅读(8854)
推荐(0)
Qt的gzip模块实现
摘要:一直没找到Qt中方便的gzip模块,于是自己动手,调用zlib模块实现了一份. 目标: 1.gzip的压缩与解压 2.内存中操作 3.方便的Qt接口 实现分析: gzip 压缩算法为 deflate inflateInit2时要求zlib库忽略zlib header gzip 在 deflate ...
阅读全文
posted @
2014-04-26 16:02
淡菊
阅读(5119)
推荐(0)
Delphi与Qt在Windows下使用共享内存进程间通信
摘要:Delphi部分 type TGuardInfo=record Lock: Integer; end; PGuardInfo = ^TGuardInfo; TGuardShareMem=class private FHandle: THandle; FGuardInfo: PGuardInfo;...
阅读全文
posted @
2014-04-26 14:31
淡菊
阅读(1516)
推荐(0)
Qt编译postgreSQL驱动
摘要:安装postgreSQL,安装目录下的lib和bin添加到path打开Qt安装目录,找到src\plugins\sqldrivers\psql编辑psql.pro,添加INCLUDEPATH += "E:/PostgreSQL/9.2/include"LIBS += "E:/PostgreSQL/9...
阅读全文
posted @
2014-04-26 14:27
淡菊
阅读(2801)
推荐(0)
Qt播放mp3
摘要:.pro项目文件中加入 QT += phonon包含头 #include 播放文件 Phonon::MediaObject *media = new Phonon::MediaObject; Phonon::AudioOutput *audioOutput = new Phonon::AudioOu...
阅读全文
posted @
2014-04-26 14:23
淡菊
阅读(1308)
推荐(0)
Qt智能指针简明说明
摘要:下面的智能指针分别对应boost库,Qt库,c++11的智能指针boost::scoped_ptr QScopedPointer unique_ptr 在其生命期结束后会自动删除它所指的对象(确定无需共享)boost::shared_ptr QSharedPointer shared_ptr 引用计...
阅读全文
posted @
2014-04-26 14:20
淡菊
阅读(1179)
推荐(1)
Qt单元测试
摘要:单元测试之作用要完成测试用例,保证设计上的耦合依赖通过测试用例,保证覆盖率,提高程序质量QTest一些有用的静态函数QTest::qExecQTest::qSleepQTest::qWait 例子 .pro项目文件中加入QT += testlibint main(int argc, char *a...
阅读全文
posted @
2014-04-26 14:11
淡菊
阅读(4300)
推荐(0)
Qt多国语言
摘要:项目中需要多语言的部分以tr宏包含例:setWindowTitle(tr("编辑"));.pro项目文件加入CODECFORTR = utf-8 #or gbk#DEFAULTCODEC = utf-8#CODEC = utf-8TRANSLATIONS = en.ts调用工具,生成.ts文件lup...
阅读全文
posted @
2014-04-26 14:07
淡菊
阅读(423)
推荐(0)
Qt库的静态编译
摘要:一、准备软件1. MinGW (C:\Qt\MinGW)http://pan.baidu.com/share/link?shareid=174269&uk=673227135这个文件解压就可以用了。2. ActivePerl3. qt-win-opensource-4.8.4-mingw.exe (...
阅读全文
posted @
2014-04-26 14:02
淡菊
阅读(10327)
推荐(0)