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

  • SEARCH
  • Home
  • 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 995707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:45:45+00:00 2026-05-16T06:45:45+00:00

The following code works (and it’s very simple): class Scrape(QApplication): def __init__(self): super(Scrape, self).__init__(None)

  • 0

The following code works (and it’s very simple):

class Scrape(QApplication):
  def __init__(self):
    super(Scrape, self).__init__(None)
    self.webView = QWebView()
    self.webView.loadFinished.connect(self.loadFinished)
  def load(self, url):
    self.webView.load(QUrl(url))
  def loadFinished(self):
    documentElement = self.webView.page().currentFrame().documentElement()

myScrape = Scrape()
myScrape.load('http://google.com/ncr')
myScrape.exec_()

but I do not really understand why the exec_() needs to be the last call and if it needs to be then what that load() really does…? How would any of this would work if I would need to load, say, two web pages?

  • 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-16T06:45:46+00:00Added an answer on May 16, 2026 at 6:45 am

    The exec_ call starts the event loop. This is where keyboard and mouse events, timer events, as well as async slot calls are dispatched.

    The load method does what you expect: sets the Url in the view. This doesn’t need events to be processed for it to work. But if you don’t finish with exec_, there will be nothing to deal with events, or to prevent the program from just finishing up and exiting.

    The exec_ method, as the term ‘event loop’ indicates, loops until the application quits. Functions called after that won’t be called until the event loop exits.

    If you want to ‘do things’ in your program, normally you would work within the event-driven framework. To load pages, you might hook up a button that will fire an event, which is connected to a function that loads a different page. Or, you might set up a timer that calls a function that sets the Url from a list.

    An example of connecting signals and slots (from here):

    # Define a new signal called 'trigger' that has no arguments.
    trigger = QtCore.pyqtSignal()
    
    def connect_and_emit_trigger(self):
        # Connect the trigger signal to a slot.
        self.trigger.connect(self.handle_trigger)
    
        # Emit the signal.
        self.trigger.emit()
    
    def handle_trigger(self):
        # Show that the slot has been called.
    
        print "trigger signal received"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following code works def lab Proc.new { return foo1 }.call return foo2 end puts
The following code works. It animates all those components nicely CGRect logoRect = self.logoImageView.frame;
The following code works fine (it builds a generic OrderBy): public class Item {
The following code works fine #include <functional> using namespace std; using namespace std::placeholders; class
// following code works fine n open notepad... class demo { public static void
The following code works fine on Linux but throws an exception on OS X
The following code works in all browser but IE8 and below. // Create Paragraph
The following code works fine in firefox but as with many other things, I
The following code works fine: person = {:a=>:A, :b=>:B, :c=>:C} berson = {:a=>:A1, :b=>:B1,
The following code works as expected on CentOS and Ubuntu O/s but not on

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.