×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    12

    QDesktopServices doesn't open URL in browser if the browser is already open

    Hello,

    I am trying to open web browser using QDesktopServices and QProcess. QDesktopServices opens the URL in the browser iff the browser is not running else it won't do anything but, QProcess brings the browser to the foreground but doesn't load the web page. I tested this on
    a) Nokia 5230
    b) Nokia N97 mini
    c) Nokia X6, and
    d) Nokia 5800.

    If i test the same thing on the carbide emulator it works perfectly fine. Here is an example of my code:

    QDesktopServices
    Code:
    QDesktopServices::openUrl(QUrl("http://www.nokia.com"));
    QProcess
    Code:
    QStringList params;
        params << "4" << " "<< "http://www.nokia.com";
    
        QProcess *bowserProcess = new QProcess(this);
        bowserProcess->start("browserng.exe", params);
    I also went through the following links:
    1) http://wiki.forum.nokia.com/index.ph..._specified_URL
    2) http://developer.symbian.org/forum/s...ead.php?t=4800

    But, nothing made it work. Could you people please help me to figure what i might be missing.
    I am using Qt 4.6.2 with QtCreator 2.0.

    Thanks,

    Sri

  2. #2
    Registered User
    Join Date
    Jun 2010
    Posts
    12

    Re: QDesktopServices doesn't open URL in browser if the browser is already open

    Hello,

    I found a bug reported for the browser not coming to the foreground but for me the URL doens't get loaded at all. Also can't use Qt 4.7. Any workaround or any parameters or arguments which i am missing?

    http://bugreports.qt.nokia.com/browse/QTBUG-8336

    Thanks,

    Sri

  3. #3
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: QDesktopServices doesn't open URL in browser if the browser is already open

    Just report the bug!!!
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  4. #4
    Registered User
    Join Date
    Aug 2008
    Posts
    19

    Re: QDesktopServices doesn't open URL in browser if the browser is already open

    Hello,

    I am trying to use QProcess in to launch a web browser that goes to a specific weblink in my Nokia N8 which is a Symbian^3.
    I was searching on google and found this discussion post. If anyone knows the answer to this question please let me know.

    Thanks.

  5. #5
    Registered User
    Join Date
    Oct 2009
    Posts
    27

    Question Re: QDesktopServices doesn't open URL in browser if the browser is already open

    I am bumping this thread sinceI can't find a solution.

    I have made a simple test application that I run on a Nokia C7 Astound device on RDA, and if the web browser is open it won't load the web page or display the browser in the foreground when I call openUrl. I have added the SwEvent capability as you can see below and signed with Open Signed Online. Anyone know if I'm doing something wrong?

    TestOpenUrl.pro
    Code:
    QT       += core gui
    
    TARGET = TestOpenUrl
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    
    CONFIG += mobility
    MOBILITY = 
    
    symbian {
        TARGET.UID3 = 0xe94b9e85
        TARGET.CAPABILITY += SwEvent
        TARGET.EPOCSTACKSIZE = 0x14000
        TARGET.EPOCHEAPSIZE = 0x020000 0x800000
    }
    MainWindow.cpp
    Code:
    void MainWindow::buttonClicked()
    {
        QDesktopServices::openUrl(QUrl(tr("http://www.forum.nokia.com")));
    }

  6. #6
    Registered User
    Join Date
    Oct 2009
    Posts
    27

    Re: QDesktopServices doesn't open URL in browser if the browser is already open

    Forget this, I just had to do a clean build after adding the SwEvent capability to the pro file. Now it works.

    Quote Originally Posted by kls_ View Post
    I am bumping this thread sinceI can't find a solution.

    I have made a simple test application that I run on a Nokia C7 Astound device on RDA, and if the web browser is open it won't load the web page or display the browser in the foreground when I call openUrl. I have added the SwEvent capability as you can see below and signed with Open Signed Online. Anyone know if I'm doing something wrong?

    TestOpenUrl.pro
    Code:
    QT       += core gui
    
    TARGET = TestOpenUrl
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    
    CONFIG += mobility
    MOBILITY = 
    
    symbian {
        TARGET.UID3 = 0xe94b9e85
        TARGET.CAPABILITY += SwEvent
        TARGET.EPOCSTACKSIZE = 0x14000
        TARGET.EPOCHEAPSIZE = 0x020000 0x800000
    }
    MainWindow.cpp
    Code:
    void MainWindow::buttonClicked()
    {
        QDesktopServices::openUrl(QUrl(tr("http://www.forum.nokia.com")));
    }

  7. #7
    Registered User
    Join Date
    Apr 2011
    Posts
    83

    Re: QDesktopServices doesn't open URL in browser if the browser is already open

    Use following code to close browser if it already open , through task list (TApaTaskList ).


    browserlauncher.cpp

    #include <QUrl>
    #include <QMessageBox>

    BrowserLauncher::BrowserLauncher()
    {
    }

    void BrowserLauncher::LaunchBrowser(const QUrl& url) {
    #if defined(Q_WS_S60)
    QString theUrl = url.toString();
    TPtrC16 textPtr(reinterpret_cast<const TUint16*>(theUrl.utf16()));
    HBufC *param = HBufC::NewMaxLC(textPtr.Length());
    param->Des().Copy(textPtr);

    RApaLsSession apaLsSession;
    const TUid KBrowserUid = {0x10008D39};

    TApaTaskList taskList(CEikonEnv::Static()->WsSession());
    TApaTask task = taskList.FindApp(KBrowserUid);
    if (task.Exists()){
    // Switch to existing browser instance
    //task.BringToForeground();
    task.EndTask();
    HBufC8* param8 = HBufC8::NewLC(param->Length());
    param8->Des().Append(*param);
    task.SendMessage(TUid::Uid(0), *param8); // UID not used
    CleanupStack::PopAndDestroy(param8);

    }
    else {
    if(!apaLsSession.Handle()) {
    User::LeaveIfError(apaLsSession.Connect());
    }
    TThreadId thread;
    User::LeaveIfError(apaLsSession.StartDocument(*param, KBrowserUid, thread));
    apaLsSession.Close();
    }

    CleanupStack::PopAndDestroy(param);
    #else
    //QDesktopServices:penUrl(url);
    #endif
    }

    browserlauncher.h file code:

    #ifndef BROWSERLAUNCHER_H
    #define BROWSERLAUNCHER_H

    class QUrl;

    class BrowserLauncher
    {
    public:
    BrowserLauncher();
    static void LaunchBrowser(const QUrl& url);
    };

    #endif // BROWSERLAUNCHER_H



    add LIBS to the project file.
    LIBS += -lcone -lavkon -lefsrv


    and call as:

    BrowserLauncher::LaunchBrowser(QUrl("http://www.yahoo.com"));

Similar Threads

  1. One more time: How to observe URL currently open in Web Browser?
    By hokkane4 in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2010-09-02, 06:46
  2. [Moved] Open a URL failed with the browser
    By yipast in forum Symbian
    Replies: 5
    Last Post: 2010-07-09, 08:08
  3. How to open more than one URL in browser?
    By SymbianTH in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2010-05-01, 07:53
  4. Replies: 13
    Last Post: 2006-01-29, 17:15
  5. Replies: 1
    Last Post: 2003-12-01, 14:17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×