[Qt-interest] Problems with QX11Embed(Container|Widget)

Denis Dzyubenko denis.dzyubenko at trolltech.com
Mon Aug 3 11:33:50 CEST 2009


Hi Louai,

Louai Al-Khanji wrote:
> I'm having some trouble using the xembed widgets. For some reason the
> client is never visible in the container.

The reason is that you never actually show the client. Adding 
'xembed.show()' seems to solve your problem.

> Client:
> 
> #include <QApplication>
> #include <QX11EmbedWidget>
> #include <QLabel>
> #include <QHBoxLayout>
> #include <QDebug>
> 
> int main(int argc, char** argv)
> {
>     QApplication app(argc, argv);
> 
>     if (argc != 2) {
>         qDebug() << "Usage:" << argv[0] << "<wid>";
>         return 0;
>     }
> 
>     WId id;
>     bool ok;
> 
>     id = QString(argv[1]).toInt(&ok);
>     if (!ok) {
>         qDebug() << "Invalid window id";
>     }
> 
>     qDebug() << "Will embed into" << id;
> 
>     QX11EmbedWidget xembed;
>     QHBoxLayout lay;
>     QLabel label("HELLO");
> 
>     lay.addWidget(&label);
>     xembed.setLayout(&lay);
>     xembed.embedInto(id);

       xembed.show();

> 
>     return app.exec();
> }


-- 
Denis Dzyubenko
Software Engineer
Nokia, Qt Software



More information about the Qt-interest-old mailing list