PDA

View Full Version : WekKit won't load JPEG images.



andrem
8th December 2008, 21:20
Hi

I am compiling a trivial "Hello World" type application that uses WebKit. I am able to browse the web perfectly from any PC with Qt tools installed, but when deploying on a different PC, I can't see any JPEG images.

I initially had side-by-side DLL issues which I resolved (I think). I am using Visual Studio 2005 with SP1. It works on all PC's that I have installed Qt SDK but on any PC that is "non-development", all JPEG images are absent (although I can browse the web).

I have compiled with qtplugin support. In the code below, I test that I can load the plugins using the QPluginLoader object and they successfully load everywhere. Why is it then that WebKit can't seem to find them! I am deploying with the following: Microsoft.VC80.CRT.manifest,msvcp80.dll,msvcr80.dl l,qgif4.dll, qjpeg4.dll, QtCore4.dll, QtGui4.dll,qtiff4.dll, QtNetwork4.dll, QtWebKit4.dll, QtXml4.dll

My source code is below and a complete project containing all the sources is attached.

Note: I have even tried putting the compiled qt sample "C:\Qt\4.4.3\demos\browser\browser.exe" in the same directory and it has the same result - no JPEG images are displayed! (but other than that, it works).

Please Help!

Thanks
Andre


------- HelloWebkit.cpp


#include <QApplication>
#include <QLabel>

#include <QPluginLoader>

#include "MyBrowser.h"

int main(int argc, char* argv[])
{
QApplication app(argc, argv);

QString strAppDir = app.applicationDirPath();
QCoreApplication::addLibraryPath(strAppDir);

QPluginLoader jpegPluginLoad("qjpeg4.dll");
jpegPluginLoad.load();
if (true==jpegPluginLoad.isLoaded())
{
QMessageBox mb(QMessageBox::Information,"jpegPluginLoad","jpegPluginLoad plugin was loaded");
mb.exec();
}
else
{
QString errorMessage = jpegPluginLoad.errorString();
QMessageBox mb(QMessageBox::Information,"",errorMessage);
mb.exec();
}

QPluginLoader gifPluginLoad("qgif4.dll");
gifPluginLoad.load();
if (true==gifPluginLoad.isLoaded())
{
QMessageBox mb(QMessageBox::Information,"","gifPluginLoad plugin was loaded");
mb.exec();
}
else
{
QString errorMessage = gifPluginLoad.errorString();
QMessageBox mb(QMessageBox::Information,"gifPluginLoad",errorMessage);
mb.exec();
}

CMyBrowser* myBrowser = new CMyBrowser();
myBrowser->show();
return app.exec();
}

---------- MyBrowser.h


#ifndef __MY_BROWSER_H
#define __MY_BROWSER_H

#include <QtGui>
#include <QtWebKit>

class CMyBrowser : public QDialog
{
Q_OBJECT;
public:
CMyBrowser(QWidget* parent = NULL);
virtual ~CMyBrowser();

private slots:
void slotLinkClicked(const QUrl& location);
void slotLoadFinished(bool ok);
void slotUnsupportedContent(QNetworkReply* reply);
void slotTitleChanged(const QString & title);

protected:
QWebView* m_webkitBrowser;
};

#endif

---------- MyBrowser.cpp




CMyBrowser::CMyBrowser(QWidget* parent)
: QDialog(parent)
, m_webkitBrowser(NULL)
{
m_webkitBrowser = new QWebView(this);

connect(m_webkitBrowser, SIGNAL(titleChanged(const QString &)), this, SLOT(slotTitleChanged(const QString &)));
connect(m_webkitBrowser, SIGNAL(linkClicked(const QUrl & )), this, SLOT(slotLinkClicked(const QUrl & )));
connect(m_webkitBrowser, SIGNAL(loadFinished(bool )), this, SLOT(slotLoadFinished(bool )));
connect(m_webkitBrowser->page(), SIGNAL(unsupportedContent(QNetworkReply*)), this,
SLOT(slotUnsupportedContent(QNetworkReply*)));
m_webkitBrowser->page()->setForwardUnsupportedContent(true);

QHBoxLayout* layout = new QHBoxLayout();
layout->addWidget(m_webkitBrowser);
QString url("http://www.google.com");
m_webkitBrowser->setUrl(url);
setLayout(layout);
}

CMyBrowser::~CMyBrowser()
{
}

void CMyBrowser::slotLinkClicked(const QUrl& location)
{
}


void CMyBrowser::slotLoadFinished(bool ok)
{
}


void CMyBrowser::slotUnsupportedContent(QNetworkReply* reply)
{
}

void CMyBrowser::slotTitleChanged(const QString & title)
{
}

---- HelloWebkit.pro


################################################## ####################
# Automatically generated by qmake (2.01a) Mon Dec 8 10:55:54 2008
################################################## ####################

TEMPLATE = app
QT = core gui webkit
TARGET =
DEPENDPATH += .
INCLUDEPATH += .

# Input
HEADERS += MyBrowser.h

SOURCES += MyBrowser.cpp \
HelloWebkit.cpp

patrik08
9th December 2008, 11:40
Here your new running main
qt load self all image plug-in
you must only copy path
%QTDIR%\plugins\imageformats to applicationpath\imageformats or make an installer



#include <QApplication>
#include "MyBrowser.h"

int main(int argc, char* argv[])
{
QApplication app(argc, argv);

CMyBrowser* myBrowser = new CMyBrowser();
myBrowser->show();
return app.exec();
}

andrem
9th December 2008, 18:48
Hi

Thanks for your advice. But it still doesn't work. I have even re-installed Qt 4.4.3 on my dev system and used "browser.exe" sample along with the needed Qt dlls and the plugins in the "imageformats" sub-directory. It still doesn't work on certain systems and I don't know why. Same thing, certain images are not showing.

Please help

Thanks
Andre

wysota
9th December 2008, 19:29
Where exactly did you put the image plugins in the target system?

rexi
10th December 2008, 00:24
you must only copy path
%QTDIR%\plugins\imageformats to applicationpath\imageformats or make an installer

Great, I just had the same problem when I came across this post :)

@andrem: Are you putting the plugin DLLs in the right place? The DLLs have to be in a folder named "imageformats" directly below the folder your application executable is in. This way it works for me, my application is finally displaying images in WebKit.

Or maybe it's a problem with the release/debug versions of the DLLs, did you copy the right ones?