PDA

View Full Version : Release program failed to show jpg image on another PC!



bangqianchen
31st January 2010, 04:18
I have release my program and package the program with installshield, and installed the package program on another PC that without QT and VS installed, everything is sames fine. I have a dialog to show image, this dialog can show jpg,png and other format image on my developing environment PC, however, it only show png image correctly on the other PC ! I had package the qgif4.dll, qjpeg4.dll and corresponding dlls to my program. the fellowing is my codes, these codes for showing images was rewriten as the QtDemo/SQL/Drill down example.


// ImageItem.cpp
#include "ImageItem.h"

CImageItem::CImageItem( QGraphicsItem *parent, QGraphicsScene *scene)
: QGraphicsPixmapItem(parent, scene)
{
setAcceptsHoverEvents(false);
timeLine.setDuration(150);
timeLine.setFrameRange(0, 150);

connect(&timeLine, SIGNAL(frameChanged(int)), this, SLOT(setFrame(int)));
connect(&timeLine, SIGNAL(finished()), this, SLOT(updateItemPosition()));
}

void CImageItem::setItem(int w,int h,const QPixmap &pixmap)
{
m_nW = w, m_nH = h;
setPixmap(pixmap);
adjust();
}

void CImageItem::hoverEnterEvent(QGraphicsSceneHoverEve nt * /*event*/)
{
timeLine.setDirection(QTimeLine::Forward);

if (z != 1.0)
{
z = 1.0;
updateItemPosition();
}

if (timeLine.state() == QTimeLine::NotRunning)
timeLine.start();
}

void CImageItem::hoverLeaveEvent(QGraphicsSceneHoverEve nt * /*event*/)
{
timeLine.setDirection(QTimeLine::Backward);
if (z != 0.0) z = 0.0;

if (timeLine.state() == QTimeLine::NotRunning)
timeLine.start();
}

void CImageItem::setFrame(int frame)
{
adjust();
QPointF center = boundingRect().center();

translate(center.x(), center.y());
scale(1 + frame / 550.0f, 1 + frame / 550.0f); // here change the scale
translate(-center.x(), -center.y());
}

void CImageItem::adjust()
{
QMatrix matrix;
matrix.scale(m_nW/ boundingRect().width(), m_nH/ boundingRect().height());
setMatrix(matrix);
}

void CImageItem::updateItemPosition()
{
setZValue(z);
}


and ImageView.cpp is here:


#include "ImageView.h"
#include "ImageItem.h"

CImageView::CImageView(int imgWidth,int imgHight,int offsetX,int offsetY,QWidget *parent): QGraphicsView(parent)
{
m_nW = imgWidth,m_nH = imgHight;
m_pGraphScene = new QGraphicsScene(this);
m_pImageItem = new CImageItem;
setScene(m_pGraphScene);
m_pImageItem->setPos(offsetX,offsetY);
m_pGraphScene->addItem(m_pImageItem);
setRect(imgWidth,imgHight,offsetX,offsetY);
}

CImageView::~CImageView()
{

}

void CImageView::setRect(int imgWidth,int imgHight,int offsetX,int offsetY)
{
int frameWidth = imgWidth + offsetX * 2 + 2;
int frameHight = imgHight + offsetY * 2 + 2;
m_pGraphScene->setSceneRect(0,0,imgWidth+2*offsetX, imgHight+offsetY*2);
}

void CImageView::showImage(const QString& szName)
{
if(!QFile::exists(szName))
{
AlarmBox(tr("Image File 【%1】 Not Found!").arg(szName));
return ;
}
m_pImageItem->setItem(m_nW,m_nH,QPixmap(szName));
}


when I want to show a image, call showImage(path) instead. and on my main.cpp, I had setted envrionment path like this:


QStringList pathList=QApplication::libraryPaths();
pathList.append(QDir::current().absolutePath()+"/plugins");
pathList.append(QApplication::applicationDirPath() +"/plugins");
QApplication::setLibraryPaths(pathList);

and in the program install folder, the files struct is like this:
D:\PROGRAM FILES\FLOWERDATABASE
│ DatabaseConfig.ini
│ FlowerDatabase.exe
│ Mainframe_zh.qm
│ Microsoft.VC90.CRT.manifest
│ msvcm90.dll
│ msvcp90.dll
│ msvcr90.dll

├─Backup
│ SQL2000_Init.bak
│ SQL2005_Init.bak

├─Config
│ style.txt

├─Database
└─Plugins
├─codecs
│ qcncodecs4.dll
│ qgif4.dll
│ qjpeg4.dll
│ qtiff4.dll
│ qtwcodecs4.dll

└─sqldrivers
qsqlite4.dll
qsqlmysql4.dll
qsqloci4.dll
qsqlodbc4.dll
It's sames everythis is OK, I don't know what's the matter! Anything help is appreciate!

wirasto
31st January 2010, 05:57
Copy qjpeg4.dll in plugins directory not in codecs directory

faldzip
31st January 2010, 09:33
image formats plugins should be in APP_ROOT_DIR/imageformats

P.S. Please search the forum next time, as this question appears once a week and the answer is always the same.

bangqianchen
31st January 2010, 15:59
Thank you for your suggestion, I will be carefull next time, and you are right, the image dll should be in a "imageformats" folder. another name may failed.

wirasto
31st January 2010, 23:16
Oh right. I'm wrong. In imageformats folder

Sorry ;)