Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, May 2008
QGraphicsScene on another QGraphicsScene


Message 1 in thread

Hi!

Is there any way to show contents of one QGraphicsScene on another
QGraphicsScene? I tryed to write some code to achieve that:

    QGraphicsView *parentView = new QGraphicsView(this);
    QGraphicsScene *parentScene = new QGraphicsScene(QRectF(0.0, 0.0,
500.0, 500.0), this);
    parentView->setScene(parentScene);
   
    QGraphicsView *childView = new QGraphicsView;
    QGraphicsScene *childScene = new QGraphicsScene(QRectF(0.0, 0.0,
250.0, 250.0), childView);
    childView->setScene(childScene);
   
    QGraphicsProxyWidget *w = parentScene->addWidget(childView);
    w->setPos(100.0, 100.0);
    w->resize(300.0, 300.0);
   
    childScene->addRect(QRectF(0.0, 0.0, 100.0, 100.0)); // this rect I
can see
   
    w = childScene->addWidget(new QPushButton("Hello!")); // but this
widget I can't see :(
    w->setPos(0.0, 0.0);
    w->resize(100.0, 100.0);

as result I can see rect, added to child scene, but can't see push
button. Any ideas?

--
 [ signature omitted ] 

Message 2 in thread

casper wrote:
> Hi!
>
> Is there any way to show contents of one QGraphicsScene on another
> QGraphicsScene? I tryed to write some code to achieve that:
>
>     QGraphicsView *parentView = new QGraphicsView(this);
>     QGraphicsScene *parentScene = new QGraphicsScene(QRectF(0.0, 0.0,
> 500.0, 500.0), this);
>     parentView->setScene(parentScene);
>    
>     QGraphicsView *childView = new QGraphicsView;
>     QGraphicsScene *childScene = new QGraphicsScene(QRectF(0.0, 0.0,
> 250.0, 250.0), childView);
>     childView->setScene(childScene);
>    
>     QGraphicsProxyWidget *w = parentScene->addWidget(childView);
>     w->setPos(100.0, 100.0);
>     w->resize(300.0, 300.0);
>    
>     childScene->addRect(QRectF(0.0, 0.0, 100.0, 100.0)); // this rect I
> can see
>    
>     w = childScene->addWidget(new QPushButton("Hello!")); // but this
> widget I can't see :(
>     w->setPos(0.0, 0.0);
>     w->resize(100.0, 100.0);
>
> as result I can see rect, added to child scene, but can't see push
> button. Any ideas?
>
>   

So, no ideas at all?

--
 [ signature omitted ] 

Message 3 in thread

Casper wrote on Wednesday, 14 May 2008 17:46

> Hi!
> 
> Is there any way to show contents of one QGraphicsScene on another
> QGraphicsScene? I tryed to write some code to achieve that:
> 
>     QGraphicsView *parentView = new QGraphicsView(this);
>     QGraphicsScene *parentScene = new QGraphicsScene(QRectF(0.0, 0.0,
> 500.0, 500.0), this);
>     parentView->setScene(parentScene);
>    
>     QGraphicsView *childView = new QGraphicsView;
>     QGraphicsScene *childScene = new QGraphicsScene(QRectF(0.0, 0.0,
> 250.0, 250.0), childView);
>     childView->setScene(childScene);
>    
>     QGraphicsProxyWidget *w = parentScene->addWidget(childView);
>     w->setPos(100.0, 100.0);
>     w->resize(300.0, 300.0);
>    
>     childScene->addRect(QRectF(0.0, 0.0, 100.0, 100.0)); // 
> this rect I
> can see
>    
>     w = childScene->addWidget(new QPushButton("Hello!")); // but this
> widget I can't see :(
>     w->setPos(0.0, 0.0);
>     w->resize(100.0, 100.0);
> 
> as result I can see rect, added to child scene, but can't see push
> button. Any ideas?

Hi Casper, 

I'm not sure what GraphicsView does when two items have exactly the same
size, that is, which order it draws them. 

Trying changing the z-order of the push button to ensure that it is in front
of the rectangle, or offset their coordinates. 

Hope that helps, 

Tony Rietwyk

--
 [ signature omitted ]