Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6721719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:21:44+00:00 2026-05-26T09:21:44+00:00

This is in Python/PySide. I am trying to create my own Parental WebBrowser by

  • 0

This is in Python/PySide.

I am trying to create my own Parental WebBrowser by overloading the PySide.QtWebKit.QWebView widget. Then whenever someone clicks a link on the widget I check to see if we are going to an invalid website, if not we proceed, if yes then I redirect to a generic page.

So I have subclassed the PySide.QtWebKit.QWebView, but I am not receiving notification of when a link is clicked. I have overridden the linkClicked function but the function never runs when a link is clicked?

What am I doing wrong? Why cant my function run/react to the hyperlink click “event”? Do I need to override the webpage object & not this class to react to link clicks?

import PySide.QtWebKit
import sys
from PyQt4 import QtGui


class BrowserWindow( PySide.QtWebKit.QWebView ):
    # Class Variables:

    def __init__( self, _parent ):
        """ Constructor: """

        super(BrowserWindow, self).__init__()
        PySide.QtWebKit.QWebView(None)


    def linkClicked(self, arg__1):
        """ Post: """

        #print("LINK CLICKED")
        #text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog', 
        #    'Enter your name:')

        self.load("http://yahoo.com")


def main():

    app = QtGui.QApplication(sys.argv)

    view = BrowserWindow(None) #PySide.QtWebKit.QWebView(None)
    view.load("http://google.com")
    view.show()

    sys.exit(app.exec_())


if __name__ == '__main__':
    main()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:21:45+00:00Added an answer on May 26, 2026 at 9:21 am

    There are several problems with the code you posted. Firstly, you are importing both PySide and PyQt4, which is not a good idea. Secondly, QWebView.linkClicked is a signal, not a protected method, so you can’t override it. Thirdly, you are passing a string to QWebView.load, when you should be passing a QtCore.QUrl.

    However, aside from those problems, you also need to set the linkDelegationPolicy on the web page in order to override its link handling.

    Here’s an edited version of your code which should fix all the problems:

    from PySide import QtCore, QtGui, QtWebKit
    
    class BrowserWindow(QtWebKit.QWebView):
        def __init__(self, parent=None):
            super(BrowserWindow, self).__init__()
            self.linkClicked.connect(self.handleLinkClicked)
    
        def handleLinkClicked(self, url):
            print(url.toString())
    
    if __name__ == '__main__':
    
        import sys
        app = QtGui.QApplication(sys.argv)
        view = BrowserWindow()
        view.load(QtCore.QUrl("http://google.com"))
        view.page().setLinkDelegationPolicy(
            QtWebKit.QWebPage.DelegateAllLinks)
        view.show()
        sys.exit(app.exec_())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a menu with PySide. This is the code def
I'm trying to get this Python MYSQL update statement correct(With Variables): cursor.execute (UPDATE tblTableName
i have written this python program. whenever i run the script using parameters like
i am trying this python script: import httplib import urllib conn = httplib.HTTPConnection(moodle.tau.ac.il) conn.request(POST
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python
Consider this Python program which uses PyGtk and Hippo Canvas to display a clickable
Consider this python program: import sys lc = 0 for line in open(sys.argv[1]): lc
Consider this Python code for printing a list of comma separated values for element
Consider this Python snippet: for a in range(10): if a == 7: pass if
I've got this python dictionary mydict, containing arrays, here's what it looks like :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.