Giter Site home page Giter Site logo

qt_eventdispatcher_libevent's Introduction

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 :-)

qt_eventdispatcher_libevent's People

Contributors

sjinks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qt_eventdispatcher_libevent's Issues

Cannot work with Qt5.10.1 on Win7 SP1 32bit

the log output:

QObject::moveToThread: Current thread (0x701658) is not the object's thread (0x700ed0).
Cannot move to target thread (0x701658)
QThread::setEventDispatcher: Could not move event dispatcher to target thread

the code is:

int main(int argc, char *argv[])
{
    QCoreApplication::setEventDispatcher(new EventDispatcherLibEvent);
    QCoreApplication a(argc, argv);
    return a.exec();
}

the libevent_dispatcher doesn't make sense.

Any plans to port this to Qt6?

Hi there and thanks for sharing this lib.
I recently tried to port it to Qt6, however I did not succeed.

Any update from your side?

Thanks already!

can u make a version support vs2013 ide

can u make a version support vs2013 ide. or make .pro build successful(copy libevent src in project)

.pro build error in windows qcreator:

include <event2/event.h>

no such file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.