PDA

View Full Version : sending image one class to another class



rajini333
3rd June 2009, 16:38
when sending the image from one class to another class application is crashing..


Code..


if(http_id == id && http->lastResponse().statusCode() == 200)
{
QPixmap image;
QCache<QString,QPixmap>imageCache;

QByteArray imagedata = buffer->data();
image.loadFromData(imagedata);

imageCache.insert(requestByEntry.key(id),&image);
Form f;
f.set(*imageCache[URL]);
buffer->close();
}






void Form::set( const QPixmap image)
{
m_ui->label->setPixmap(image);
this->show();

}

wysota
3rd June 2009, 19:03
You are storing a pointer to a local object that gets destroyed when you leave the block of code. Store objects instead of pointers to them.

rajini333
4th June 2009, 07:38
Hi

When i am running my application , In console i am getting

QWaitCondition: Destroyed while threads are still waiting


Then application is automatically closed..

I am using http links in my code..

if i use the QmessageBox ,that time is not showing , and application is not closed..




m_ui->setupUi( this );
m_ui->blockbutton->hide();
m_ui->callbutton->hide();
m_ui->followbutton->hide();
m_ui->retweetbutton->hide();

//QMessageBox::information(0,"get image function",QString("url link got"));
m_ui->userName->setText(""+str);
m_ui->userStatus->setHtml(""+str2);
m_ui->label->setPixmap(image);
//m_ui->userImage->setPixmap(image);

m_ui->label->setMouseTracking(true);
m_ui->label->installEventFilter(this);
m_ui->callbutton->setIcon(QIcon("../Image/all.png"));
m_ui->blockbutton->setIcon(QIcon("../Image/65.png"));
m_ui->followbutton->setIcon(QIcon("../Image/follow.png"));
m_ui->retweetbutton->setIcon(QIcon("../Image/68.png"));

if i disable the message box that time application is closed

wysota
4th June 2009, 08:08
Do you use threads in your application?

rajini333
4th June 2009, 09:45
No, I didn't use the threads..


Recently I used thead in above mentioned function..

QThread::wait(5000);

But nothing happened...