1 Star 1 Fork 1

graycatya / qt_eventdispatcher_libevent

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

qt_eventdispatcher_libevent Build Status

libevent-based event dispatcher for Qt

Features

  • very fast :-)
  • compatibile with Qt 4 (Qt 4.2+) and Qt 5
  • does not use any private Qt headers
  • passes Qt 4 and Qt 5 event dispatcher, event loop, timer and socket notifier tests

Unsupported Features

  • QSocketNotifier::Exception (libevent offers no support for this)
  • Qt 5/Windows only: QWinEventNotifier is not supported (registerEventNotifier() and unregisterEventNotifier() functions are currently implemented as stubs; libevent does not natively support Windows events and addition of the support to the event dispatcher will mean a completely different event loop code for Windows).

Requirements

  • libevent >= 2.0.0 (the code seems to work with libevent 1.4.x but this has not been tested much — but the Qt tests are successfully passed though)
  • Qt >= 4.2 (tests from tests-qt4 were run only on Qt 4.8.x, 4.5.4, 4.3.0, 4.2.1)

Build

cd src
qmake
make

Replace make with nmake if your are using Microsoft Visual C++.

The above commands will generate the static library and .prl file in ../lib directory.

Install

After completing Build step run

*NIX:

sudo make install

Windows:

nmake install

For Windows this will copy eventdispatcher_libevent.h and eventdispatcher_libevent_config.h to ../lib directory. For *NIX this will install eventdispatcher_libevent.h to /usr/include, libeventdispatcher_libevent.a and libeventdispatcher_libevent.prl to /usr/lib, eventdispatcher_libevent.pc to /usr/lib/pkgconfig.

Usage (Qt 4)

Simply include the header file and instantiate the dispatcher in main() before creating the Qt application object.

#include "eventdispatcher_libevent.h"
    
int main(int argc, char** argv)
{
    EventDispatcherLibEvent dispatcher;
    QCoreApplication app(argc, argv);

    // ...

    return app.exec();
}

And add these lines to the .pro file:

unix {
    CONFIG    += link_pkgconfig
    PKGCONFIG += eventdispatcher_libevent
}
else:win32 {
    include(/path/to/qt_eventdispatcher_libevent/lib/eventdispatcher_libevent.pri)
}

or

HEADERS += /path/to/eventdispatcher_libevent.h
LIBS    += -L/path/to/library -leventdispatcher_libevent

Usage (Qt 5)

Simply include the header file and instantiate the dispatcher in main() before creating the Qt application object.

#include "eventdispatcher_libevent.h"

int main(int argc, char** argv)
{
    QCoreApplication::setEventDispatcher(new EventDispatcherLibEvent);
    QCoreApplication app(argc, argv);

    // ...

    return app.exec();
}

And add these lines to the .pro file:

unix {
    CONFIG    += link_pkgconfig
    PKGCONFIG += eventdispatcher_libevent
}
else:win32 {
    include(/path/to/qt_eventdispatcher_libevent/lib/eventdispatcher_libevent.pri)
}

or

HEADERS += /path/to/eventdispatcher_libevent.h
LIBS    += -L/path/to/library -leventdispatcher_libevent

Qt 5 allows to specify a custom event dispatcher for the thread:

QThread* thr = new QThread;
thr->setEventDispatcher(new EventDispatcherLibEvent);

Interesting Facts

EventDispatcherLibEvent is more compatible with Qt 4.2.x and 4.3.x than the native UNIX event dispatcher from those Qt's.

For example, Qt 4.2.1 fails tst_QTimer::livelock(zero timer) and tst_QTimer::livelock(non-zero timer) tests ('tester.postEventAtRightTime' returned FALSE) and hangs in tst_QEventLoop::processEventsExcludeTimers test but EventDispatcherLibEvent passes them all!

It should, however, be noted that these tests were taken from Qt 4.8 :-)

Copyright (c) 2012-2013 Vladimir Kolesnikov <vladimir@free-sevastopol.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

libevent-based event dispatcher for Qt 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/graycatya/qt_eventdispatcher_libevent.git
git@gitee.com:graycatya/qt_eventdispatcher_libevent.git
graycatya
qt_eventdispatcher_libevent
qt_eventdispatcher_libevent
master

搜索帮助