Results 1 to 6 of 6

Thread: embedding X11

  1. #1
    Join Date
    Jul 2008
    Posts
    48
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default embedding X11

    Hi everyone,

    I'm creating an interface that calls on a program with a given set of parameters, and then the program is run with QProcess, but it is displayed in a sepparate X11 window

    I would like to embed this in the Mainwindow, but I'm not sure how to do this. Any ideas?

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: embedding X11

    use QX11EmbedContainer; you need to wait for your program to get started and find out its X11 window id
    (some programs let you pass a window id they should embed into, too)

  3. #3
    Join Date
    Jul 2008
    Posts
    48
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: embedding X11

    Hi caduel,

    I am testing it out with xlogo. I tried it on Mac, it didn't compile. It said that QX11EmbedContainer class didn't exist. Is this class available for Macs?

    I tried it on unix, and it worked compiled and ran, however I don't see the logo embedded in the application. I think it's because I don't know the windows id, how do I find that id?

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: embedding X11

    macs: sorry. don't have one. i think that it should work on macs if and only if the mac is running X11.

    window id: to find the window id of an existing window: use X11 calls to traverse (query) the window tree and find the window e.g. thru comparing window titles. (see X11 calls like XQueryTree, XWindowName, ...).

  5. #5
    Join Date
    Jul 2008
    Posts
    48
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: embedding X11

    So if I understand correctly, the x11 program I want to run embeded, must have a way to specify the winId. Otherwise the QX11EmbedContainer will not work. This is the code that runs but doesn't work, I think it doesn't have a way to specify the winId as an argument.

    Qt Code:
    1. #include <QX11EmbedContainer>
    2. #include <QtGui>
    3. #include <QProcess>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. if (app.arguments().count() != 2) {
    10. qFatal("Error - expected executable path as argument");
    11. return 1;
    12. }
    13.  
    14. QX11EmbedContainer container;
    15. container.show();
    16.  
    17. QProcess process(&container);
    18. QString executable(app.arguments()[1]);
    19. QStringList arguments;
    20. arguments << QString::number(container.winId());
    21. process.start(executable, arguments);
    22.  
    23. int status = app.exec();
    24. process.close();
    25. return status;
    26. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: embedding X11

    this is one way: if an app allows you to pass a window id for rendering into, then you can do that.

    if you have an app that does not allow you to pass a window id that way, then you call QX11EmbedContainer::embedClient() with the window id of the client app.
    (To do that: start the app, wait for the window to exist, get its window id, then call embedClient with that id.)

Similar Threads

  1. embed_manifest_exe not embedding manifest in exe
    By Sirmont in forum Qt Programming
    Replies: 0
    Last Post: 3rd February 2009, 19:54
  2. Replies: 0
    Last Post: 20th November 2008, 15:20
  3. Embedding Flash in Qt4 app,On Mac OS X
    By larntin in forum Qt Programming
    Replies: 0
    Last Post: 21st June 2007, 10:12
  4. Embedding
    By shrikarcse in forum Newbie
    Replies: 1
    Last Post: 27th March 2006, 19:06
  5. Embedding Java in Qt
    By learnerplts in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2006, 15:45

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.