• April 27, 2024, 03:11:34 pm

Author Topic: How to open a file externally  (Read 2280 times)

0 Members and 1 Guest are viewing this topic.

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
How to open a file externally
« on: October 24, 2013, 11:41:17 pm »
for Delight App I had to find a way to open a .sis inside of the app, the default Qt way is simple:
Code: [Select]
QDesktopServices::openUrl(QUrl("file:///C:/data/test.sis));
but it does open the service framework and hides your app.

There's a simple native function to open it directly in your UI:

1. Link against: apgrfx.lib in your .pro file, this means add
Code: [Select]
LIBS += -lapgrfx
2. in your class include:
Code: [Select]
#include <apgcli.h>
3. into you method paste this:
Code: [Select]
        RApaLsSession apaLsSession;
CleanupClosePushL(apaLsSession );
User::LeveIfError(apaLsSession.Connect());
TThreadId threadId;
        apaLsSession.StartDocument((_L("C:\\data\\test.sis")), threadId);
        CleanupStack::PopAndDestroy(&apaLsSession );

you also can use a QString and convert it to a native string via:
Code: [Select]
TPtrC16 symstring(reinterpret_cast<const TUint16*>(qstring.utf16()));
« Last Edit: October 29, 2013, 05:20:08 pm by huellif »

Offline symster

  • Developer
  • Happy Member
  • ****
  • Posts: 214
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : Nokia N8 Soon Nokia 808
Re: How to open a file externally
« Reply #1 on: October 26, 2013, 06:09:42 pm »
Hmm...kind of confusing the way you explain it

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Re: How to open a file externally
« Reply #2 on: October 29, 2013, 04:48:40 pm »
maybe you should know Symbian C++ a little bit


*Updated first post with correct exception handling
« Last Edit: October 29, 2013, 05:58:26 pm by huellif »

Offline Motaz

  • Developer
  • Forum User
  • ****
  • Posts: 62
  • Reputation: 72
  • Symbian Power User
  • Current Phone: : Nokia 700
Re: How to open a file externally
« Reply #3 on: October 29, 2013, 06:30:06 pm »
Thank you huellif, you always the best ;)

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Re: How to open a file externally
« Reply #4 on: October 29, 2013, 06:37:47 pm »
Thank you huellif, you always the best ;)

lol I am bloody as hell with native code, I just share what I know