QX11EmbedWidget Class

The QX11EmbedWidget class provides an XEmbed client widget. 更多...

頭: #include <QX11EmbedWidget>
繼承: QWidget

公共類型

enum Error { Unknown, InvalidWindowID }

公共函數

QX11EmbedWidget (QWidget * parent = 0)
~QX11EmbedWidget ()
WId containerWinId () const
void embedInto (WId id )
Error error () const

信號

void containerClosed ()
void 嵌入式 ()
void error (QX11EmbedWidget::Error error )

重實現保護函數

virtual bool event (QEvent * event )
virtual void resizeEvent (QResizeEvent * event )

額外繼承成員

詳細描述

The QX11EmbedWidget class provides an XEmbed client widget.

XEmbed is an X11 protocol that supports the embedding of a widget from one application into another application.

An XEmbed client widget is a window that is embedded into a container . A container is the graphical location that embeds (or swallows ) an external application.

QX11EmbedWidget is a widget used for writing XEmbed applets or plugins. When it has been embedded and the container receives tab focus, focus is passed on to the widget. When the widget reaches the end of its focus chain, focus is passed back to the container. Window activation, accelerator support, modality and drag and drop (XDND) are also handled.

The widget and container can both initiate the embedding. If the widget is the initiator, the X11 window ID of the container that it wants to embed itself into must be passed to embedInto ().

If the container initiates the embedding, the window ID of the embedded widget must be known. The container calls embed(), passing the window ID.

This example shows an application that embeds a QX11EmbedWidget subclass into the window whose ID is passed as a command-line argument:

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    if (app.arguments().count() != 2) {
        qFatal("Error - expected window id as argument");
        return 1;
    }
    QString windowId(app.arguments()[1]);
    EmbedWidget window;
    window.embedInto(windowId.toULong());
    window.show();
    return app.exec();
}
					

The problem of obtaining the window IDs is often solved by the container invoking the application that provides the widget as a separate process (as a panel invokes a docked applet), passing its window ID to the new process as a command-line argument. The new process can then call embedInto () with the container's window ID, as shown in the example code above. Similarly, the new process can report its window ID to the container through IPC, in which case the container can embed the widget.

When the widget has been embedded, it emits the signal 嵌入式 (). If it is closed by the container, the widget emits containerClosed (). If an error occurs when embedding, error () 發射。

There are XEmbed widgets available for KDE and GTK+. The GTK+ equivalent of QX11EmbedWidget is GtkPlug. The corresponding KDE 3 widget is called QXEmbed.

另請參閱 QX11EmbedContainer and XEmbed Specification .

成員類型文檔編製

enum QX11EmbedWidget:: Error

常量 描述
QX11EmbedWidget::Unknown 0 An unrecognized error occurred.
QX11EmbedWidget::InvalidWindowID 2 The X11 window ID of the container was invalid. This error is usually triggered by passing an invalid window ID to embedInto ().

成員函數文檔編製

QX11EmbedWidget:: QX11EmbedWidget ( QWidget * parent = 0)

構造 QX11EmbedWidget 對象采用給定 parent .

QX11EmbedWidget:: ~QX11EmbedWidget ()

銷毀 QX11EmbedWidget object. If the widget is embedded when deleted, it is hidden and then detached from its container, so that the container is free to embed a new widget.

[signal] void QX11EmbedWidget:: containerClosed ()

This signal is emitted by the client widget when the container closes the widget. This can happen if the container itself closes, or if the widget is rejected.

The container can reject a widget for any reason, but the most common cause of a rejection is when an attempt is made to embed a widget into a container that already has an embedded widget.

WId QX11EmbedWidget:: containerWinId () const

If the widget is embedded, returns the window ID of the container; otherwize returns 0.

void QX11EmbedWidget:: embedInto ( WId id )

When this function is called, the widget embeds itself into the container whose window ID is id .

id is not the window ID of a container this function will behave unpredictably.

[signal] void QX11EmbedWidget:: 嵌入式 ()

This signal is emitted by the widget that has been embedded by an XEmbed container.

Error QX11EmbedWidget:: error () const

Returns the type of error that occurred last. This is the same error code that is emitted by the error() signal.

另請參閱 Error .

[signal] void QX11EmbedWidget:: error ( QX11EmbedWidget::Error error )

This signal is emitted if an error occurred as a result of embedding into or communicating with a container. The specified error describes the problem that occurred.

注意: 信號 error 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:

connect(x11EmbedWidget, static_cast<void(QX11EmbedWidget::*)(QX11EmbedWidget::Error)>(&QX11EmbedWidget::error),
    [=](QX11EmbedWidget::Error error){ /* ... */ });
					

另請參閱 QX11EmbedWidget::Error .

[virtual protected] bool QX11EmbedWidget:: event ( QEvent * event )

重實現自 QObject::event ().

[virtual protected] void QX11EmbedWidget:: resizeEvent ( QResizeEvent * event )

重實現自 QWidget::resizeEvent ().