Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QCopChannel Class Reference
[QtGui module]

The QCopChannel class provides communication capabilities between several clients. More...

#include <QCopChannel>

Inherits QObject.

Public Functions

  • 28 public functions inherited from QObject

Signals

  • void received ( const QString & msg, const QByteArray & data )

Static Public Members

  • bool isRegistered ( const QString & channel )
  • bool send ( const QString & channel, const QString & msg, const QByteArray & data )
  • bool send ( const QString & channel, const QString & msg )
  • 4 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 7 protected functions inherited from QObject

Detailed Description

The QCopChannel class provides communication capabilities between several clients.

The Qt Cop (QCOP) is a COmmunication Protocol, allowing clients to communicate both within the same address space and between different processes.

Currently, this facility is only available for Qt/Embedded. On X11 and Windows we are exploring the use of existing standards such as DCOP and COM.

QCopChannel provides send() and isRegistered() which are static functions usable without an object.

The channel() function returns the name of the channel.

In order to listen to the traffic on a channel, you should either subclass QCopChannel and reimplement receive(), or connect() to the received() signal.


Member Function Documentation

QCopChannel::QCopChannel ( const QString & channel, QObject * parent = 0 )

Constructs a QCop channel and registers it with the server using the name channel. The standard parent argument is passed on to the QObject constructor.

QCopChannel::~QCopChannel ()   [virtual]

Destroys the client's end of the channel and notifies the server that the client has closed its connection. The server will keep the channel open until the last registered client detaches.

QString QCopChannel::channel () const

Returns the name of the channel.

bool QCopChannel::isRegistered ( const QString & channel )   [static]

Queries the server for the existence of channel.

Returns true if channel is registered; otherwise returns false.

void QCopChannel::receive ( const QString & msg, const QByteArray & data )   [virtual]

This virtual function allows subclasses of QCopChannel to process data received from their channel.

The default implementation emits the received() signal.

Note that the format of data has to be well defined in order to extract the information it contains.

Example:

    void MyClass::receive(const QString &msg, const QByteArray &data)
    {
        QDataStream in(data);
        if (msg == "execute(QString,QString)") {
            QString cmd;
            QString arg;
            in >> cmd >> arg;
            ...
        } else if (msg == "delete(QString)") {
            QString fileName;
            in >> fileName;
            ...
        } else {
            ...
        }
    }

This example assumes that the msg is a DCOP-style function signature and the data contains the function's arguments. (See send().)

Using the DCOP convention is a recommendation, but not a requirement. Whatever convention you use the sender and receiver must agree on the argument types.

See also send().

void QCopChannel::received ( const QString & msg, const QByteArray & data )   [signal]

This signal is emitted with the msg and data whenever the receive() function gets incoming data.

bool QCopChannel::send ( const QString & channel, const QString & msg, const QByteArray & data )   [static]

Send the message msg on channel channel with data data. The message will be distributed to all clients subscribed to the channel.

Note that QDataStream provides a convenient way to fill the byte array with auxiliary data.

Example:

    QByteArray data;
    QDataStream out(&data, QIODevice::WriteOnly);
    out << QString("cat") << QString("file.txt");
    QCopChannel::send("System/Shell", "execute(QString,QString)",
                      data);

Here the channel is "System/Shell". The msg is an arbitrary string, but in the example we've used the DCOP convention of passing a function signature. Such a signature is formatted as "functionname(types)" where types is a list of zero or more comma-separated type names, with no whitespace, no consts and no pointer or reference marks, i.e. no "*" or "&".

Using the DCOP convention is a recommendation, but not a requirement. Whatever convention you use the sender and receiver must agree on the argument types.

See also receive().

bool QCopChannel::send ( const QString & channel, const QString & msg )   [static]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Send the message msg on channel channel. The message will be distributed to all clients subscribed to the channel.

See also receive().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.0
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web