QX11EmbedContainer Class

The QX11EmbedContainer class provides an XEmbed container widget. 更多...

頭: #include <QX11EmbedContainer>
繼承: QWidget
繼承者:

公共類型

enum Error { Unknown, InvalidWindowID }

公共函數

QX11EmbedContainer (QWidget * parent = 0)
~QX11EmbedContainer ()
WId clientWinId () const
void discardClient ()
void embedClient (WId id )
Error error () const

信號

void clientClosed ()
void clientIsEmbedded ()
void error (QX11EmbedContainer::Error error )

重實現保護函數

virtual bool event (QEvent * event )
virtual void paintEvent (QPaintEvent * e )

額外繼承成員

詳細描述

The QX11EmbedContainer class provides an XEmbed container widget.

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

An XEmbed container is the graphical location that embeds an external client widget . A client widget is a window that is embedded into a container.

When a widget 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.

QX11EmbedContainer is commonly used for writing panels or toolbars that hold applets, or for swallowing X11 applications. When writing a panel application, one container widget is created on the toolbar, and it can then either swallow another widget using embed(), or allow an XEmbed widget to be embedded into itself. The container's X11 window ID, which is retrieved with winId (), must then be known to the client widget. After embedding, the client's window ID can be retrieved with clientWinId ().

In the following example, a container widget is created as the main widget. It then invokes an application called "playmovie", passing its window ID as a command line argument. The "playmovie" program is an XEmbed client widget. The widget embeds itself into the container using the container's window ID.

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    if (app.arguments().count() != 2) {
        qFatal("Error - expected executable path as argument");
        return 1;
    }
    QX11EmbedContainer container;
    container.show();
    QProcess process(&container);
    QString executable(app.arguments()[1]);
    QStringList arguments;
    arguments << QString::number(container.winId());
    process.start(executable, arguments);
    int status = app.exec();
    process.close();
    return status;
}
					

When the client widget is embedded, the container emits the signal clientIsEmbedded (). The signal clientClosed () is emitted when a widget is closed.

It is possible for QX11EmbedContainer to embed XEmbed widgets from toolkits other than Qt, such as GTK+. Arbitrary (non-XEmbed) X11 widgets can also be embedded, but the XEmbed-specific features such as window activation and focus handling are then lost.

The GTK+ equivalent of QX11EmbedContainer is GtkSocket. The corresponding KDE 3 widget is called QXEmbed.

另請參閱 QX11EmbedWidget and XEmbed Specification .

成員類型文檔編製

enum QX11EmbedContainer:: Error

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

成員函數文檔編製

QX11EmbedContainer:: QX11EmbedContainer ( QWidget * parent = 0)

創建 QX11EmbedContainer 對象采用給定 parent .

QX11EmbedContainer:: ~QX11EmbedContainer ()

銷毀 QX11EmbedContainer .

[signal] void QX11EmbedContainer:: clientClosed ()

This signal is emitted by the container when the client widget closes.

[signal] void QX11EmbedContainer:: clientIsEmbedded ()

This signal is emitted by the container when a client widget has been embedded.

WId QX11EmbedContainer:: clientWinId () const

If the container has an embedded widget, this function returns the X11 window ID of the client; otherwise it returns 0.

void QX11EmbedContainer:: discardClient ()

Detaches the client from the embedder. The client will appear as a standalone window on the desktop.

void QX11EmbedContainer:: embedClient ( WId id )

Instructs the container to embed the X11 window with window ID id . The client widget will then move on top of the container window and be resized to fit into the container.

The id should be the ID of a window controlled by an XEmbed enabled application, but this is not mandatory. If id does not belong to an XEmbed client widget, then focus handling, activation, accelerators and other features will not work properly.

Error QX11EmbedContainer:: error () const

返迴最後齣現的錯誤。

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

This signal is emitted if an error occurred when embedding or communicating with a client. The specified error describes the problem that occurred.

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

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

另請參閱 QX11EmbedContainer::Error .

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

重實現自 QObject::event ().

[virtual protected] void QX11EmbedContainer:: paintEvent ( QPaintEvent * e )

重實現自 QWidget::paintEvent ().