Results 1 to 18 of 18

Thread: QX11EmbedContainer problem

  1. #1
    Join Date
    Dec 2006
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QX11EmbedContainer problem

    Hi guys,

    After having spent considerable time trying to debug this myself,
    I have decided to post a question here.

    I'm trying to embed a non-Qt X11 application into my own application
    using QX11EmbedContainer. I'm using Qt4. Example:

    QX11EmbedContainer *test=new QX11EmbedContainer(parent);
    QProcess *process=new QProcess(test);
    process->start(QString("/usr/bin/xclock"));

    What happens is that the container widget is created perfectly, xclock
    appears on the screen, but not inside the container. I read there are
    keyboard focus limitations, but at least the xclock window should be
    reparented if I am not mistaken. Other X11 tools (even qtconfig)
    behave in the same manner.

    I would be very grateful if someone could shed some light onto this!

    Martin

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QX11EmbedContainer problem

    IMO the problem is that the application you want to embed doesn't know about this, so you have to use QX11EmbedContainer::embedClient().

    See attachment for a small test program (you can retrieve window id using xwininfo and paste it directly into line edit).
    Attached Files Attached Files

  3. #3
    Join Date
    Dec 2006
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QX11EmbedContainer problem

    Thank you for your reply and your example. However, the documentation states:

    "Arbitrary (non-XEmbed) X11 widgets can also be embedded, but the XEmbed-specific features such as window activation and focus handling are then lost."

    Every X Window manager reparents windows to 'swallow' them to put decoration around them, so I am convinced the Qt container widget is meant to do this too.

    I would like to embed a text editor (more capable than QTextEdit) and cannot rewrite this to use QX11EmbedWidget.

    Martin

    Quote Originally Posted by jacek View Post
    IMO the problem is that the application you want to embed doesn't know about this, so you have to use QX11EmbedContainer::embedClient().

    See attachment for a small test program (you can retrieve window id using xwininfo and paste it directly into line edit).

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QX11EmbedContainer problem

    Quote Originally Posted by Martin42 View Post
    I would like to embed a text editor (more capable than QTextEdit) and cannot rewrite this to use QX11EmbedWidget.
    I've never played with QX11EmbedWidget before, but it looks like you just have to know the window id of that editor. You probably can find it using some XLib calls (like XQueryTree()).

  5. #5
    Join Date
    Dec 2006
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QX11EmbedContainer problem

    If that is the way it works, then Qt is not very much of assistance here.

    Well, I tried it anyway, getting the window id of a running application using xwininfo. Passing this to my application at least does something... The original window disappears but still does not appear in the container.

    Having read something about bugs in this area in Qt 4 or 4.2 specifically, I was wondering whether anyone actually has experience with these calls.

    Maybe a question to pass to one of the Qt developers?

    Quote Originally Posted by jacek View Post
    I've never played with QX11EmbedWidget before, but it looks like you just have to know the window id of that editor. You probably can find it using some XLib calls (like XQueryTree()).

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QX11EmbedContainer problem

    Quote Originally Posted by Martin42 View Post
    If that is the way it works, then Qt is not very much of assistance here.
    It musn't be necessarily Qt's fault, but rather it's the way XEmbed works.

    Quote Originally Posted by Martin42 View Post
    Having read something about bugs in this area in Qt 4 or 4.2 specifically, I was wondering whether anyone actually has experience with these calls.
    Indeed it doesn't always work with Qt 4.2 (at least when I tried my test app with xclock), but I couldn't find anything in the task tracker.

    Quote Originally Posted by Martin42 View Post
    Maybe a question to pass to one of the Qt developers?
    It's hard to find them here. Better contact Trolltech support or try qt-interest mailing list.

  7. #7
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QX11EmbedContainer problem

    I have done this. If the window is not an XEmbedClient, then you need to know its window ID. You can get this with xwininfo or similar methods. I am attaching a sample program that does this, which I have used to embed XEmacs, xterm, etc.

    XEmbed is intended for XEmbed-aware clients. Otherwise all it does is swallow apps, making it a poor-man's window manager.

    p.s. There was a bug in 4.2.0-rc1, but it has been resolved.
    Attached Files Attached Files

  8. The following 5 users say thank you to Brandybuck for this useful post:

    amit.tomar (19th August 2011), cochise (22nd November 2010), developDavid (6th July 2010), wagmare (2nd December 2008), wirthmi (10th May 2011)

  9. #8
    Join Date
    Dec 2006
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QX11EmbedContainer problem

    Compiling you example has been extremely helpful, thanks. It worked! I had in fact tried the following code earlier:

    QX11EmbedContainer *test=new QX11EmbedContainer(parent);
    test->embedClient(winid);
    test->show();

    which is very very similar, but doesn't work. The only difference I can think of is that in my case, there has not been time enough for the container window to be realised, so the embedding fails. It seems you need to wait for the container to appear on screen. That will probably be possible some way.

    Next is the problem of knowing the winid of the process you forked, automatically, as I can't expect my users to use xwininfo....

    Cheers.

    Martin

    Quote Originally Posted by Brandybuck View Post
    I have done this. If the window is not an XEmbedClient, then you need to know its window ID. You can get this with xwininfo or similar methods. I am attaching a sample program that does this, which I have used to embed XEmacs, xterm, etc.

    XEmbed is intended for XEmbed-aware clients. Otherwise all it does is swallow apps, making it a poor-man's window manager.

    p.s. There was a bug in 4.2.0-rc1, but it has been resolved.

  10. #9
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QX11EmbedContainer problem

    Quote Originally Posted by Martin42 View Post
    It seems you need to wait for the container to appear on screen.
    The client needs the container's X11 window to be embedded into. From your behavior, I'm assuming it isn't being created until the widget is shown for the first time. So either call show() before embedClient(), or embed the client in the showEvent() method.

  11. #10
    Join Date
    Dec 2006
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QX11EmbedContainer problem

    show() (immediately) before embedClient() doesn't work, so I will go for the latter.
    Thanks for your help!

    Martin

    Quote Originally Posted by Brandybuck View Post
    The client needs the container's X11 window to be embedded into. From your behavior, I'm assuming it isn't being created until the widget is shown for the first time. So either call show() before embedClient(), or embed the client in the showEvent() method.

  12. #11

    Default Re: QX11EmbedContainer problem

    I have a similiar problem.

    If I use "QProcess" to invoke an external application, how can I get the winId of that application?

  13. #12
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QX11EmbedContainer problem

    You have to iterate through all the windows until you find it.

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QX11EmbedContainer problem

    Either use X11 calls to get it or ask the process for it. Maybe it has a way of telling you its winId.

  15. #14
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QX11EmbedContainer problem

    Quote Originally Posted by wysota View Post
    Either use X11 calls to get it or ask the process for it. Maybe it has a way of telling you its winId.
    He can use at most the PID of the process.

  16. #15

    Default Re: QX11EmbedContainer problem

    I want to embed an external application in my window. I use "QX11EmbedContainer" and "QProcess". However, it does not work. The application can be executed, but it isn't embedded in the container.
    my code is :

    QX11EmbedContainer container(0);
    container.show();
    QProcess proc(&container);
    QString executable("kpdf");
    QStringList arguments;
    arguments << QString::number(container.winId());
    proc.start(executable, arguments);

  17. #16
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: QX11EmbedContainer problem

    hi friends,
    the program Mr.Brandybuck is excellent and its work fine in my app where i want to embed a GTK window to my Qt widget ..
    is the window id of the GTK winow changes by time because i am entering window id of the running gtk window ...
    if it changes by time or execution how can i get id of the external program (gtk)

  18. #17
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: QX11EmbedContainer problem

    Quote Originally Posted by yumiko View Post
    I have a similiar problem.

    If I use "QProcess" to invoke an external application, how can I get the winId of that application?
    this system call works fine after we start the external program by QProcess : xwininfo -root -all | grep ' " Window Title " ' |awk '{print $1}'

    Window title is the running QProcess execution's title

  19. #18
    Join Date
    May 2011
    Posts
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QX11EmbedContainer problem

    I am using the the container for a xEmbed Widget in the same scope and expect the widget to get embedded in the container but i am getting two window not a single window, the code is like this...
    int main(int argc, char*argv[])
    {
    QApplication app(argc,argv)
    QX11EmbedContainer container;
    QX11EmbedWidget window;
    container.show();
    window.embedInto(container.WinID());
    container.embedclient(window.winID());
    int status= app.exec();
    return status;
    }

    Ideally i shud be getting only a single window but i am getting two separate window.

    What could be the problem????????

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.