Harmattan Booster for Qt Quick Applications: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Manually Enabling Harmattan Booster Library=
[[Category:Snippets]]<br />[[Category:Developing with Qt]]<br />[[Category:HowTo]]<br />[[Category:Tools::QtCreator]]


Up until and including Qt Creator 2.3.0, the “Qt Quick Application” wizard doesn’t make use of the Harmattan booster library. This has a negative impact on application startup time, and might even lead to problems when submitting the application to the Ovi store.
[toc align_right=&quot;yes&amp;quot; depth=&quot;3&amp;quot;]


''Qt Creator 2.3.1 (which is now included in the latest updates to the Qt <span class="caps">SDK</span>) already enables the booster by default! The instructions below are only for people who have already projects created with 2.3.0 or older, or are not willing to update for whatever reasons.''
= Manually Enabling Harmattan Booster Library =
 
Up until and including Qt Creator 2.3.0, the &quot;Qt Quick Application&amp;quot; wizard doesn't make use of the Harmattan booster library. This has a negative impact on application startup time, and might even lead to problems when submitting the application to the Ovi store.
 
''Qt Creator 2.3.1 (which is now included in the latest updates to the Qt SDK) already enables the booster by default! The instructions below are only for people who have already projects created with 2.3.0 or older, or are not willing to update for whatever reasons.''


This page outlines the changes you can do by hand to the source code to enable the booster. However, by making these changes your application will not compile any more for other targets!
This page outlines the changes you can do by hand to the source code to enable the booster. However, by making these changes your application will not compile any more for other targets!


==Changes to main.cpp==
== Changes to main.cpp ==
 
Replace your main.cpp with following code (obviously replacing &quot;YourApp&amp;quot; by the name of your app):


Replace your main.cpp with following code (obviously replacing “YourApp” by the name of your app):
<code><br />#include &lt;QtGui/QApplication&amp;gt;<br />#include &lt;QtDeclarative/QDeclarativeView&amp;gt;<br />#include &lt;QtDeclarative/QDeclarativeEngine&amp;gt;<br />#include &lt;MDeclarativeCache&amp;gt;


==Changes to .pro file==
Q_DECL_EXPORT int main(int argc, char *argv[])<br />{<br /> QScopedPointer&amp;lt;QApplication&amp;gt; app(MDeclarativeCache::qApplication(argc, argv));<br /> QScopedPointer&amp;lt;QDeclarativeView&amp;gt; view(MDeclarativeCache::qDeclarativeView());
 
view-&gt;setSource(MDeclarativeCache::applicationDirPath()<br /> + QLatin1String(&quot;/../qml/YourApp/main.qml&amp;quot;));
 
QObject::connect(view-&gt;engine(), SIGNAL (quit()), view.data(), SLOT (close()));
 
view-&gt;showFullScreen();
 
app-&gt;exec&amp;amp;#40;&amp;#41;;<br />}<br /></code>
 
== Changes to .pro file ==


Add
Add


to the .pro file, and don’t forget to do a full recompile!
<code><br />CONFIG += qdeclarative-boostable<br /></code>


==Changes to .desktop file==
to the .pro file, and don't forget to do a full recompile!
 
== Changes to .desktop file ==


Open YourApp_harmattan.desktop in the project directory, and change
Open YourApp_harmattan.desktop in the project directory, and change
<code><br />Exec=/usr/bin/single-instance /opt/YourApp/bin/YourApp<br /></code>


to
to
<code><br />Exec=/usr/bin/invoker —type=d -s /opt/YourApp/bin/YourApp<br /></code>


''Do you have questions, or suggestions? Raise them under http://developer.qt.nokia.com/forums/viewthread/9164''
''Do you have questions, or suggestions? Raise them under http://developer.qt.nokia.com/forums/viewthread/9164''
===Categories:===
* [[:Category:Developing with Qt|Developing_with_Qt]]
* [[:Category:HowTo|HowTo]]
* [[:Category:snippets|snippets]]
* [[:Category:Tools|Tools]]
** [[:Category:Tools::QtCreator|QtCreator]]

Revision as of 10:25, 24 February 2015




[toc align_right="yes&quot; depth="3&quot;]

Manually Enabling Harmattan Booster Library

Up until and including Qt Creator 2.3.0, the "Qt Quick Application&quot; wizard doesn't make use of the Harmattan booster library. This has a negative impact on application startup time, and might even lead to problems when submitting the application to the Ovi store.

Qt Creator 2.3.1 (which is now included in the latest updates to the Qt SDK) already enables the booster by default! The instructions below are only for people who have already projects created with 2.3.0 or older, or are not willing to update for whatever reasons.

This page outlines the changes you can do by hand to the source code to enable the booster. However, by making these changes your application will not compile any more for other targets!

Changes to main.cpp

Replace your main.cpp with following code (obviously replacing "YourApp&quot; by the name of your app):

<br />#include &lt;QtGui/QApplication&amp;gt;<br />#include &lt;QtDeclarative/QDeclarativeView&amp;gt;<br />#include &lt;QtDeclarative/QDeclarativeEngine&amp;gt;<br />#include &lt;MDeclarativeCache&amp;gt;

Q_DECL_EXPORT int main(int argc, char *argv[])<br />{<br /> QScopedPointer&amp;lt;QApplication&amp;gt; app(MDeclarativeCache::qApplication(argc, argv));<br /> QScopedPointer&amp;lt;QDeclarativeView&amp;gt; view(MDeclarativeCache::qDeclarativeView());

view-&gt;setSource(MDeclarativeCache::applicationDirPath()<br /> + QLatin1String(&quot;/../qml/YourApp/main.qml&amp;quot;));

QObject::connect(view-&gt;engine(), SIGNAL (quit()), view.data(), SLOT (close()));

view-&gt;showFullScreen();

app-&gt;exec&amp;amp;#40;&amp;#41;;<br />}<br />

Changes to .pro file

Add

<br />CONFIG += qdeclarative-boostable<br />

to the .pro file, and don't forget to do a full recompile!

Changes to .desktop file

Open YourApp_harmattan.desktop in the project directory, and change

<br />Exec=/usr/bin/single-instance /opt/YourApp/bin/YourApp<br />

to

<br />Exec=/usr/bin/invoker type=d -s /opt/YourApp/bin/YourApp<br />

Do you have questions, or suggestions? Raise them under http://developer.qt.nokia.com/forums/viewthread/9164