Results 1 to 2 of 2

Thread: QWebView - opening links in external browser?

  1. #1
    Join Date
    Aug 2010
    Posts
    2

    Default QWebView - opening links in external browser?

    I can't seem to be able to figure out how to get this work.
    I have a webview in my app, and I want every link clicked on it to open in the system's default browser. The app lets the user choose one from a list of URLs and displays a small description webpage of said url, which has a link to the actual website. I want this link to be opened in an external browser.

    This is what I have, regarding the problem:

    App.cpp:

    Qt Code:
    1. webWidget = new QWebView(this);
    2.  
    3. webWidget->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
    4.  
    5. connect(webWidget, SIGNAL(linkClicked (const QUrl &)), this, SLOT(urlClicked(const QUrl &)));
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void App::urlClicked(QUrl & link)
    2. {
    3. qDebug() << link.toString();
    4. QDesktopServices::openUrl(link);
    5. }
    To copy to clipboard, switch view to plain text mode 
    and in App.h,the slot
    Qt Code:
    1. void urlClicked(QUrl & link);
    To copy to clipboard, switch view to plain text mode 


    But since the QUrl never gets sent to the slot(the debug line doesn't print anything), I'm assuming I'm missing something, but haven't been able to figure out what it is.

  2. #2
    Join Date
    Sep 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QWebView - opening links in external browser?

    implement the createwindow of the qwebpage class..

Similar Threads

  1. Opening a browser in MAC
    By gren15 in forum Newbie
    Replies: 2
    Last Post: 30th June 2009, 16:54
  2. QWebview's links
    By TejWC in forum Qt Programming
    Replies: 1
    Last Post: 6th July 2008, 19:37
  3. How to Open External Links?
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2008, 06:47
  4. open an external links
    By sudheer in forum Qt Tools
    Replies: 4
    Last Post: 17th January 2008, 04:50
  5. open HTTP links in pop up browser
    By mnemonic_fx in forum Qt Programming
    Replies: 1
    Last Post: 26th September 2007, 06:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.