Results 1 to 9 of 9

Thread: Problem With QWebView

  1. #1
    Join Date
    Feb 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem With QWebView

    Hi.
    I have problem with QWebView (QWebPage)

    Need make script for load html page like:


    Qt Code:
    1. QWebView * view = new QWebView();
    2. connect(view, SIGNAL(linkClicked ( const QUrl & )), this, SLOT(newsOnLinkClicked ( const QUrl & )));
    3. view->load(QUrl("http://newsroot.net"));
    4. view->show();
    To copy to clipboard, switch view to plain text mode 
    Works fine.
    Problem there need open all links in default browser like Firefox or IE.

    I try all settings.
    Qt Code:
    1. QWebPage * wpage = new QWebPage ();
    2. connect(wpage, SIGNAL(linkClicked ( const QUrl & )), this, SLOT(newsOnLinkClicked ( const QUrl & )));
    3. wpage->setLinkDelegationPolicy (QWebPage::DelegateAllLinks);
    4. QWebView * view = new QWebView();
    5. wpage->triggerAction(QWebPage::OpenLink,true);
    6. view->triggerPageAction(QWebPage::OpenLink,true);
    7. connect(view, SIGNAL(linkClicked ( const QUrl & )), this, SLOT(newsOnLinkClicked ( const QUrl & )));
    8. wpage->setView(view);
    9. view->load(QUrl("http://newsroot.net"));
    10. view->show();
    To copy to clipboard, switch view to plain text mode 
    Possible some lines not need.

    Please help.
    Last edited by jpn; 24th March 2008 at 15:41. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem With QWebView

    How did you implement newsOnLinkClicked() slot?

  3. #3
    Join Date
    Feb 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem With QWebView

    I can't disable follow links in QWebView too.

    -----------------------------

    Window.h

    Qt Code:
    1. public slots:
    2. void newsOnLinkClicked ( const QUrl & );
    To copy to clipboard, switch view to plain text mode 
    Window.cpp

    Qt Code:
    1. void Window::newsOnLinkClicked ( const QUrl & url )
    2. {
    3. QDesktopServices::openUrl(url);
    4. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 24th March 2008 at 15:42. Reason: missing [code] tags

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem With QWebView

    Quote Originally Posted by ivi2501 View Post
    I can't disable follow links in QWebView too.
    Do I understand correctly that all links are opened both in external browser and QWebView?

  5. #5
    Join Date
    Feb 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem With QWebView

    All links must be opened in external browser.
    I have site, need make software api for this site.
    My Sites:
    http://admintools.org.ua
    http://newsroot.net

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem With QWebView

    How about this?
    Qt Code:
    1. QWebView * view = new QWebView();
    2. connect( view, SIGNAL(linkClicked( const QUrl & )), this, SLOT(newsOnLinkClicked( const QUrl & )) );
    3. view->load( QUrl( "http://newsroot.net" ) );
    4. view->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
    5. view->show();
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to jacek for this useful post:

    ivi2501 (21st March 2008)

  8. #7
    Join Date
    Feb 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem With QWebView

    Nice !!!!!!!!!!
    Works fine.
    Thank You

  9. #8
    Join Date
    Feb 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem With QWebView

    Please help with another problem.


    I need disable context menu for QWebView

  10. #9
    Join Date
    Jul 2009
    Posts
    21
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem With QWebView

    view->setContextMenuPolicy(Qt::NoContextMenu);

Similar Threads

  1. PyQt QTimer problem { FIXED }
    By WinchellChung in forum Newbie
    Replies: 0
    Last Post: 1st March 2008, 17:50
  2. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 11:35
  3. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 13:54
  4. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 15:08
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

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.