PDA

View Full Version : Embed an external application to the widget



acix
9th April 2006, 13:06
Hi guys, i need some help.
I'm trying to do some project in order to learn Qt (thats the best way of learning i think) .
Anyway, I want to embed an external process to a widget, specifically the mplayer process.
so I m creating the process mplayer and i want it to be displayed into my widget, so i can
have control over it.
Thank you guys in advance,
btw, this is my firts post
good job for the forum

wysota
9th April 2006, 17:05
With mplayer it is fairly easy. Use a -wid parameter with mplayer and as an argument specify window id (returned by QWidget::winId()) of the widget you want to embed the player in.

nupul
10th April 2006, 06:04
what incase of a generic application? eg java applet or something of that sort?

wysota
10th April 2006, 09:40
what incase of a generic application? eg java applet or something of that sort?

This comes down to the Xlib layer then, I guess. There is a Qt Solution (http://www.trolltech.com/products/solutions/catalog/3/Widgets/qtxembed/) which does that.

nupul
10th April 2006, 10:11
well i don't think it needs to come down to the Xlib layer...The Qt4 Doc cites QX11EmbedContainer and QX11EmbedWidget to achieve the same....

Honestly, i didn't know about this class till this thread :p
I went to the link you gave and had a look through the docs for the same...

Thanks
Nupul.

wysota
10th April 2006, 10:58
Doesn't it only allow embedding applications which allow that by allowing to specify a window ID to open into?

nupul
10th April 2006, 11:55
Doesn't it only allow embedding applications which allow that by allowing to specify a window ID to open into?

yes.
well i didn't clarify....what i meant was any application that ran in some window i.e. a gui based app.

:)
nupul

acix
10th April 2006, 12:45
With mplayer it is fairly easy. Use a -wid parameter with mplayer and as an argument specify window id (returned by QWidget::winId()) of the widget you want to embed the player in.

Thank you guys for your replies.
So basically what u mean is that just passing the windId to the mplayer -wid parameter will embed mplayer to the widget which i got the windId. sounds pretty much easy.
I knew about QX11EmbedContainer and had a look before but i got a bit confused, thats why i posted here, i guess i am just a newbie :)
I ll try this thing out.
thanks again

wysota
10th April 2006, 13:40
yes.
well i didn't clarify....what i meant was any application that ran in some window i.e. a gui based app.


No, that's the problem. Not any app, just the ones which use XEmbed (which is of course in XLib layer).

fullmetalcoder
10th April 2006, 16:37
any way to perform such an embedding under window$ ???
Qt is cross-platform isn't it?;)

Brandybuck
28th September 2006, 03:02
Let me open up this thread again, because I am having a problem with it. I can get MPlayer embedded using its -wid parameter. But I am unable to embed any window by passing the WindowID to QX11EmbedContainer::embedClient. The old Qt3 solution sample code doesn't work (after porting to qt4 of course), and neither does the QDevBlog sample for XEmbed here <http://blogs.qtdeveloper.net/archives/2005/08/10/playing-around-with-xembed/>. This is very frustrating because I know it works in Qt3, and worked long enough in Qt4 for the QDevBlog to get a screenshot of it.

I have logged this as a bug with Trolltech, but I am wondering if anyone else has seen this, and whether it's a new bug. Please use the QDevBlog sample code for discussion.

Thanks...

pellis
28th September 2006, 13:18
The QDevBlog example worked for me (SUSE 10, Qt 4.1.4) embedding Konquerer. I used xwininfo to find the window id.

Brandybuck
28th September 2006, 18:44
Doing a bit of playing around, I see that it works under 4.1.4, but not under 4.2.0-rc1. After logging four bugs in one day, I'm starting to think the "release candidate" is the wrong term to use...

bpetty
25th September 2007, 15:07
any way to perform such an embedding under window$ ???
Qt is cross-platform isn't it?;)
Sorry for reopening... but I find this to be a good question. How does one do this under Windows? I assume QX11EmbedWidget will obviously only work under X11.

And one more question since I have not used QX11Embed*, can I use these classes to essentially attach my Qt app to another window... to basically doc mine to the side for example?

rbp
18th May 2009, 02:07
How does one do this under Windows? I assume QX11EmbedWidget will obviously only work under X11.

I'm also wondering this - is it possible to embed an external application under Windows? Or only for Linux?
Richard

leenxkewl
14th October 2010, 15:15
I am just hanging to this thread, because I also have a problem with this. I am trying to embed xterm in a QDockWidget. All that I need is the wid. When passing the wid to embedClient(..) manually (via xwininfo -int) it works perfectly, but I don't see any good way of getting that wid? Ideas?

wysota
14th October 2010, 15:26
QWidget::winId()

leenxkewl
14th October 2010, 15:55
Yeah, but I mean the wid from the external application, not my own widget.

wysota
14th October 2010, 16:04
Just run xterm with "-into X" where X is the winId returned by the window you wish to embed xterm into.

leenxkewl
14th October 2010, 16:08
I tried exactly this, but xterm opens in a separate window.

edit:
Here's some code:


Shell::Shell(QWidget *parent)
: QDockWidget(parent)
{
setObjectName("Shell");
setWindowTitle("Shell");

QWidget *widget=new QWidget(this);
setWidget(widget);

process=new QProcess(this);
process->start("xterm -into "+QString((int)widget->winId()));
widget->show();
}


edit2:
I made a screenshot for you, so you can understand what I am trying to achieve:

wysota
14th October 2010, 16:41
It fails because your QString "cast" fails. Look that there is no QString constructor taking a sole int as a parameter.

leenxkewl
14th October 2010, 16:55
Oh hehe, sorry fur bugging you. Anyways, isn't there a solution to implement any foreign window?

wysota
14th October 2010, 17:44
As far as I know, there is no such solution.