PDA

View Full Version : problem in loading pixmap item to qgraphicslinearlayout



wagmare
11th October 2013, 05:48
hi friends,
i was trying to load the pixmapItem in a graphicsview using QLinearlayout . its like adding pixmap item with qfuturewatcher


imageScaling = new QFutureWatcher<QImage>(this);
connect(imageScaling, SIGNAL(resultReadyAt(int)), SLOT(showImage(int)));



View::setSceneLayout()
{
m_scene->clear();
m_baseLayout = new QGraphicsLinearLayout(Qt::Vertical);
m_baseLayout->setSpacing(8);
m_container = new QGraphicsWidget;
m_container->setLayout(m_baseLayout);

}


void
View::addItems( QStringList list ) //const QImage image, const QString &fileName)
{


if (imageScaling->isRunning()) {
imageScaling->cancel();
imageScaling->waitForFinished();
}

m_list = list;

imageScaling->setFuture(QtConcurrent::mapped(list, CheatScaled));

}


QImage
CheatScaled( const QString &imageFileName)
{
//scaling image
return qimage;
}


void
View::showImage(int num)
{
PixmapItem *pixItem = new PixmapItem(imageScaling->resultAt(num));
m_scene->addItem(pixItem);
m_baseLayout->addItem(pixItem);


}

the image is adding clearly to the graphicsview . but when the image added to the layout it shows a ghost image or a small portion of the loading image in the first item..but only at the loading time .. as it looks like flickering. for every item it adding. it is showing some kind of flickering but after it loads the item it looks normal ..

sorry i cant explain the problem clearly ..
please hep me in avoiding this effect ..

stampede
11th October 2013, 08:28
So you have so many images (and/or they are big) that you need to rescale them in separate thread ?
How frequent are the updates ? Maybe you could try just:


setUpdatesEnabled(false);
addItemsInGuiThread(...);
setUpdatesEnabled(true);

I'm just wondering if you really need separate threads to update the gui.
btw.

connect(imageScaling, SIGNAL(resultReadyAt(int)), SLOT(showImage(int)));
a typo, right ?

wagmare
11th October 2013, 11:16
yeah its in the constructor of my view ..