Results 1 to 6 of 6

Thread: Pause function flow till QWebView SIGNAL is completed

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Pause function flow till QWebView SIGNAL is completed

    If you need a utility to automate form fillings then you may want to look at curl. Some instructions are here and here.

    If you want to write your own application then (as for me) I see here a problem, that loading of a page is not a blocking operation. In this case you will have to sleep and check for the loading. So, here an approximate pseudo code:

    Qt Code:
    1. somefunction() {
    2. webView->load(yourUrl);
    3.  
    4. while (!pageLoaded()) {
    5. sleep(nSeconds);
    6. }
    7.  
    8. // do your processing here
    9. }
    To copy to clipboard, switch view to plain text mode 

    So we already have one more function, which is:

    Qt Code:
    1. bool YourModule::pageLoaded()
    2. {
    3. return mPageLoaded;
    4. }
    To copy to clipboard, switch view to plain text mode 

    Obviously mPageLoaded is set to FALSE at the very beginning, so when the page is loaded it should be set to TRUE, so that we exit that while loop. They only way we can do it (at least the only that I found) with the help of QWebView, is connect loadFinished(bool ok) signal of QWebView to your slot and your slot will set mPageLoaded to TRUE, i.e.

    Qt Code:
    1. connect(youWebView, SIGNAL(loadFinished(bool)), this, SLOT(pageLoaded(bool)));
    2. ...
    3. void YourModule::pageLoaded(bool iOk)
    4. {
    5. mPageLoaded = true;
    6. }
    To copy to clipboard, switch view to plain text mode 

    This is the solution I see at this point.
    I'm a rebel in the S.D.G.

  2. #2
    Join Date
    Oct 2010
    Posts
    4
    Qt products
    Qt4

    Default Re: Pause function flow till QWebView SIGNAL is completed

    Thanks for your hints lyuts, finally I came to solution with QEvenLoop and everything works like a charm!

  3. #3
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Pause function flow till QWebView SIGNAL is completed

    Quote Originally Posted by Timus83 View Post
    Thanks for your hints lyuts, finally I came to solution with QEvenLoop and everything works like a charm!
    So you are using its exit() and exec() functions, right?
    I'm a rebel in the S.D.G.

Similar Threads

  1. how to emit signal in a static function ?
    By cxl2253 in forum Qt Programming
    Replies: 32
    Last Post: 7th July 2016, 21:36
  2. Emit signal from const function
    By waynew in forum Qt Programming
    Replies: 9
    Last Post: 22nd August 2010, 13:10
  3. How to know when the server has completed the painting of the widget...??
    By kapoorsudhish in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 16th April 2010, 13:15
  4. static function emitting signal
    By wagmare in forum Qt Programming
    Replies: 8
    Last Post: 26th March 2010, 08:34
  5. Replies: 8
    Last Post: 27th October 2009, 09:07

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
  •  
Qt is a trademark of The Qt Company.