×
Namespaces

Variants
Actions
(Difference between revisions)

Porting iPhone Web Apps to Qt using QtWebKit

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData)
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
(4 intermediate revisions by one user not shown)
Line 1: Line 1:
[[Category:Porting]][[Category:Qt]]
+
[[Category:Porting]][[Category:Code Examples]][[Category:iPhone]][[Category:Qt WebKit]][[Category:Qt]]
{{KBCS}}
+
{{ArticleMetaData <!-- v1.2 -->
{{ArticleMetaData
+
|sourcecode= [[Media:WebApp.zip]]
|id=
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= Nokia 5800, N900
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|platform= S60, Symbian^3, Maemo
 
|platform= S60, Symbian^3, Maemo
|devices=Nokia 5800, N900 
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|category=Qt
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|subcategory= Qt for Symbian , Qt for Maemo
+
|signing= <!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= Web, WebKit, HTML, QWebView, JavaScript
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 
|creationdate= 14 November 2010
 
|creationdate= 14 November 2010
|keywords= Web, WebKit, HTML, QWebView, JavaScript
+
|author= [[User:Chintandave er]]
 
+
<!-- The following are not in current metadata -->
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
+
|subcategory= Qt, Qt for Maemo
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
+
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
+
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices.) -->
+
|author=[[User:Chintandave er]]
+
 
}}
 
}}
  
Line 27: Line 33:
 
== Main Class ==
 
== Main Class ==
  
<code cpp>
+
<code cpp-qt>
 
#include <QtGui/QApplication>
 
#include <QtGui/QApplication>
 
#include "webapp.h"
 
#include "webapp.h"
Line 46: Line 52:
 
==Header==
 
==Header==
  
<code cpp>
+
<code cpp-qt>
 
#ifndef WEBAPP_H
 
#ifndef WEBAPP_H
 
#define WEBAPP_H
 
#define WEBAPP_H
Line 76: Line 82:
 
==Source==
 
==Source==
  
<code cpp>
+
<code cpp-qt>
 
#include "webapp.h"
 
#include "webapp.h"
 
WebApp::WebApp(QWidget *parent)
 
WebApp::WebApp(QWidget *parent)
Line 123: Line 129:
 
==Source Code==
 
==Source Code==
  
You can download source code from this link [[File:WebApp.zip]][[Category:Code Examples]][[Category:iPhone]]
+
You can download source code from this link [[File:WebApp.zip]]

Latest revision as of 04:18, 11 October 2012

Article Metadata
Code Example
Source file: Media:WebApp.zip
Tested with
Devices(s): Nokia 5800, N900
Compatibility
Platform(s): S60, Symbian^3, Maemo
Article
Keywords: Web, WebKit, HTML, QWebView, JavaScript
Created: chintandave_er (14 Nov 2010)
Last edited: hamishwillee (11 Oct 2012)

Contents

[edit] Overview

This Wiki Article shows how to port iPhone Web Apps to Qt using QtWebkit

[edit] Install the Nokia Qt SDK

Install Nokia Qt SDK if you don’t already have it from here.

[edit] Main Class

#include <QtGui/QApplication>
#include "webapp.h"
 
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
WebApp w;
 
w.showFullScreen();
 
return a.exec();
}


[edit] Header

#ifndef WEBAPP_H
#define WEBAPP_H
#include <QtCore/QPointer>
#include <QtWebKit/QWebView>
#include <QtWebKit/QWebPage>
#include <QtWebKit/QWebFrame>
#include <QtGui/QWidget>
#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#include <QtGui/QFrame>
#include <QtGui/QVBoxLayout>
class WebApp : public QMainWindow
{
Q_OBJECT
public:
WebApp(QWidget *parent = 0);
~WebApp();
private:
QPointer<QWebView> _webView;
QPointer<QVBoxLayout> _layout;
void SetupApp();
};
#endif // WEBAPP_H


[edit] Source

#include "webapp.h"
WebApp::WebApp(QWidget *parent)
: QMainWindow(parent)
{
SetupApp();
}
WebApp::~WebApp()
{
}
void WebApp::SetupApp()
{
/**
* Create the central widget
* and set it.
*/

QFrame* cW = new QFrame(this);
setCentralWidget(cW);
/**
* Set the layout to central widget.
*/

_layout = new QVBoxLayout(this);
cW->setLayout(_layout);
_layout->setMargin(0);
_layout->setSpacing(0);
/**
* Let's create the web view which
* will be used to display our page.
*/

_webView = new QWebView(this);
 
// Add your iPhone Web App URL to display in Qt App
_webView->load(QUrl("http://URL"));
_webView->show();
/** Add it to layout */
_layout->addWidget(_webView);
}

[edit] Postcondition

Here is one ported iPhone web app screen snap.

IphoneWebApp.jpg


[edit] Source Code

You can download source code from this link File:WebApp.zip

This page was last modified on 11 October 2012, at 04:18.
89 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×