PDA

View Full Version : QPixmap display on QGraphicsScene



febil
26th February 2009, 09:33
In the below code i need to display images on 10 ImageViewer items. But i got image only on first ImageViewer. As per my analysis, it is working on QWidget instead of QGraphicsScene. and also it will display text on all ImageViewer items, issue is only on QPixmap. Please solve this issue.
class ImageViewer : public QGraphicsScene
{
ImageViewer( QString csImagePath_i )
{
QPixmap *pPixmap = new QPixmap( csImagePath );// "/tmp/1image" );
QGraphicsPixmapItem *pPixMapItem = new QGraphicsPixmapItem( m_pPixmap );
addItem( m_pPixMapItem );
}
}


QGraphicsScene *m_pGraphicsScene = new QGraphicsScene;
QGraphicsView *m_pGraphicsView = new QGraphicsView( m_pGraphicsScene );
QGraphicsGridLayout* m_pGridLayout = new QGraphicsGridLayout();
QGraphicsWidget* m_pGraphicsWidget = new QGraphicsWidget;
m_pGraphicsWidget->setLayout( m_pGridLayout );
m_pGraphicsScene->addItem( m_pGraphicsWidget );
for( int nVal =0; nVal < 10; nVal++ )
{
ImageViewer* pImageView = new ImageViewer( "/tmp/Image1" );
QGraphicsWidget *pGraphicsWidget = (QGraphicsWidget *)m_pGraphicsScene->addWidget( pImageView );
pGraphicsWidget->setMinimumSize( QSize( 500,500 ));
m_pGridLayout->addItem( pGraphicsWidget, nRow, nCol );
nCol++;
}

febil
26th February 2009, 09:57
The scenario is shown below
1. Create QGraphicsScene object;
2. Set QPixmap on the above created object.
3. Add it in to another QGraphicsScene.
4. Coninue the above steps multiple times.
5. There the image shown only on first added item.
6. If we add into QWidget it will working fine
7. Is there any issues in QGraphicsScene added on another QGraphicsScene

zgulser
26th February 2009, 10:27
Hi

I'am looking at. I'll report back as soon as it's done.