QImage not loading successively.
Hi,
I am loading a image from file using QImage class. After processing some steps, my application will load the image from other file to the same object. Application is exiting by segmentation fault. My Qt version is 4.4. Please provide me the solution if QImage does't handle two successive image loading.
Regards,
node_ex.
Re: QImage not loading successively.
Please provide some code that you suspect that causes the segfault.
Re: QImage not loading successively.
Hi Wysota,
Actually i figured out the issue but unable to resolve it. I am launching a thread before exec. This hinders Qimage from loading an image from file.
Regards,
node_ex.
Code :
-----------------displayimage.h--------------------
Code:
#include <QWidget>
#include <qevent.h>
//#include <QLabel>
#include <QPainter>
#include <QImage>
#include <QPaintEvent>
{
private:
protected:
public:
~displayimage();
};
------------------displayimage.cpp----------------
Code:
#include <fstream.h>
#include <iostream.h>
#include <QMessageBox>
#include <QLabel>
#include "displayimage.h"
displayimage
::displayimage(QString fileName
){
_fileName=fileName;
setWindowTitle(tr("Node Explorer"));
}
displayimage::~displayimage()
{
}
{
cout<<"B4 loading"<<endl;
_image.load(_fileName);
paint.drawImage(paint.window(),_image);
}
---------------main.cpp-------------------------
Code:
#include <QApplication>
#include <iostream.h>
#include "displayimage.h"
#include "testthread.h"
//using namespace std;
displayimage* obj;
int main(int argc, char *argv[])
{
QString fileName
("/scratchbox/Venkanna.jpg");
obj = new displayimage(fileName);
cout<<"B4 show"<<endl;
obj->show();
Test test;
test.start();
int ret = app.exec();
return ret;
}
------------------testthread.h-------------------------
Code:
#include<qthread.h>
{
public :
virtual void run();
};
void Test::run()
{
for(int count =0; count<20; count++)
{
sleep(1);
qDebug(" Thread started");
}
}
Re: QImage not loading successively.
What if you load the file in the constructor and not in the paint event?