Results 1 to 13 of 13

Thread: webview custom error pages

  1. #1
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default webview custom error pages

    hi sorry for posting alot, its just that i want to write a real chrome alternative browser, now i need to know how to create custom error pages for the browser, for example when the address is not found, when there is no network connection... i don't know what to do

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: webview custom error pages

    Have a look at QWebPage::extension().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: webview custom error pages

    thanks alot!


    Added after 56 minutes:


    please sorry, i looked at it, but iam very confused, i don't know how to reimplement that methot, this is what i wanted to try

    bool QWebPage::extension ( QWebPage::ErrorPageExtension, const ExtensionOption * option = 0, ExtensionReturn * output = 0 ) , but what else! i know how to reimplement virtual methods, but this one is verry different, iam very confused, and the demo browser don't use it at all, so i don't know where to find and example using it, please help!!!
    Last edited by wambagilles; 21st March 2011 at 20:23.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: webview custom error pages

    How is it different from other virtual methods?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: webview custom error pages

    for the other method, for example the contexMenuEvent, i just had to create the menu i wanted and add actions into it, but now i need custom error pages, and here i have seen nowhere someting very precise, i know QWebPage::extension() is the right method to use, but iam lost, i don't know where to start, please it is not tha i want you to solve the problem for me, normaly that your hint should be enough, but please help me, i spent all the day on this!

    also sorry for the quality of my english, my mother tongue is french!

    thanks!

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: webview custom error pages

    Look at the parameters you receive in the method. Cast them to a proper type based on the extension you are currently handling and fill in the return parameter based on the option parameter.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: webview custom error pages

    but the return parametter is just a boolean, how about the custom webpage i want to load in case of network error for example?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: webview custom error pages

    I'm not speaking about return value but one of the input arguments that has the type "ExtensionReturn". The other has a type of "ExtensionOption" thus my "return" and "option" names.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: webview custom error pages

    i will look at it again, and i will report here, but to be honnest, iam very lost i don't know if i should be ashamed for that, it is very abstract, i still don't know where to start and what to write, anyway thanks very much for your help, and your precious time!

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: webview custom error pages

    I will not do your work for you and I will not teach you general programming here. You should already be familiar with programming before you start doing any complex projects with Qt. Start by looking at the documentation of structures you get, the fields they have and what they should contain. Then fill those structures with data depending on the effect you want to achieve.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: webview custom error pages

    Qt Code:
    1. bool webPage::extension ( Extension extension, const ExtensionOption * option, ExtensionReturn * output ){
    2.  
    3.  
    4. const QWebPage::ErrorPageExtensionOption* info = static_cast<const QWebPage::ErrorPageExtensionOption*>(option);
    5. QWebPage::ErrorPageExtensionReturn* errorPage = static_cast<QWebPage::ErrorPageExtensionReturn*>(output);
    6. errorPage->content = QString("<html><head><title>Failed loading page</title></head><body>%1</body></html>").arg(info->errorString).toUtf8();
    7. return true;
    8.  
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 


    Added after 28 minutes:


    now it works perfect, thanks very much!!! the problem is solved
    Last edited by wysota; 23rd March 2011 at 07:25. Reason: missing [code] tags

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: webview custom error pages

    You should check the type of extension being handled before casting and using the parameters.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Feb 2011
    Posts
    55
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: webview custom error pages

    ok, thanks!

Similar Threads

  1. Custom qNetworkAccessManager for WebView
    By xeento in forum Qt Programming
    Replies: 2
    Last Post: 25th May 2010, 04:22
  2. Error in custom delegate
    By philacorns in forum Newbie
    Replies: 4
    Last Post: 21st April 2010, 05:41
  3. Custom QNetworkReply for WebView
    By victor.yacovlev in forum Qt Programming
    Replies: 0
    Last Post: 1st April 2009, 13:32
  4. Replies: 5
    Last Post: 21st February 2007, 22:11
  5. Error when promoting a custom widget
    By engin in forum Qt Tools
    Replies: 1
    Last Post: 15th December 2006, 16:00

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.