PDA

View Full Version : How to add forms(.ui file) to a QGraphicScene background



c_srikanth1984
29th January 2009, 08:50
Hi,
I have a application where there is a scene(QGraphicsScene) by using toolbox we can add items to scene. I have designed two forms(hwidget.ui, vwidget.ui) now i want to add these two to scene background, how can i do this.

wysota
29th January 2009, 09:39
You can only add them as items, not into the background layer. Create widgets out of them and use QGraphicsScene::addWidget().

c_srikanth1984
29th January 2009, 09:53
ya i have tried like that but addWidget( ) accepts QWidget object.and i have only designed two forms (hwidget.ui and vwidget.ui) do i need to create any class for that.

wagmare
29th January 2009, 10:05
try
QGraphicsProxyWidget to ur application

faldzip
29th January 2009, 16:28
ya i have tried like that but addWidget( ) accepts QWidget object.and i have only designed two forms (hwidget.ui and vwidget.ui) do i need to create any class for that.

Yes, you have to create an widget object first. Try QUiLoader. As I see in docs, it's the thing you need, but I've never tried it for myself.

wysota
29th January 2009, 20:45
Yes, you have to create an widget object first. Try QUiLoader. As I see in docs, it's the thing you need, but I've never tried it for myself.

I would advise against it. Either create proper classes based on those forms or use the direct approach which might be simpler in your case. Both are described in Using a Component in Your Application

c_srikanth1984
30th January 2009, 09:25
I could add my hwidget.ui and vwidget.ui to my scene background using this direct approch.
thank u.