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++;
}
Bookmarks