Giter VIP home page Giter VIP logo

cuteipc's Introduction

CuteIPC

Build Status

This library adds a facility to use Qt signals and slots across local processes and over TCP. Based on QLocalSocket and QTcpSocket, it is a cross platform IPC solution with native syntax for Qt programs.

Installation

CuteIPC works with both Qt4 and Qt5 and can be built using cmake or qbs.

To build using cmake:

cmake CMakeLists.txt
make
make install

To build using qbs:

qbs build profile:<profile name> 
qbs install --install-root /usr/local profile:<profile name>

Finally, add the include directory of CuteIPC to your project.

Usage

Connection

First, create a server and associate it with a desired QObject. The signals and slots of this object will be used in IPC.

CuteIPCService* service = new CuteIPCService;

// setup local server
service->listen("serverName", myObject);
// or TCP server using host and port
service->listenTcp(QHostAddress::Any, 31337, myObject);

On the other side, create the interface and connect to the server:

CuteIPCInterface* interface = new CuteIPCInterface;

// connect locally
interface->connectToServer("myServerName");
// or over TCP
interface->connectToServer(QHostAddress("192.0.2.1"), 31337);
Direct calls

You can to directly invoke any invokable method or public slot of the corresponding object. The syntax is similar to QMetaObject::invokeMethod.

  • Use call method to invoke synchronously and wait for result in the event loop:
int result;
interface->call("remoteMethod", Q_RETURN_ARG(int, result), Q_ARG(QString, methodParameter));
  • Use callNoReply to send invoke request asynchronously and return immediately:
interface->callNoReply("remoteMethod", Q_ARG(QString, methodParameter));
Signals and slots
  • You can natively connect the remote signal to a local slot:
interface->remoteConnect(SIGNAL(remoteSignal(QString)), receiver, SLOT(receiverSlot(QString)));
  • or local signal to the remote slot:
interface->remoteSlotConnect(senderObject, SIGNAL(localSignal(QString)), SLOT(remoteSlot(QString)));

Please note, that all signals are sent asynchronously.

API reference

A full API reference can be generated using doxygen in the source root.

License

LGPL 2.1

This library is contributed under LGPL 2.1 license. Feel free to contact us if you're interested in using this library on other terms.

cuteipc's People

Contributors

mtuner avatar alez1986 avatar cyberbobs avatar ivanpinezhaninov avatar

Watchers

James Cloos avatar

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.