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
Re: webview custom error pages
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!!!
Re: webview custom error pages
How is it different from other virtual methods?
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!
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.
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?
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.
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!
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.
Re: webview custom error pages
Code:
bool webPage::extension ( Extension extension, const ExtensionOption * option, ExtensionReturn * output ){
const QWebPage::ErrorPageExtensionOption* info = static_cast<const QWebPage::ErrorPageExtensionOption*>(option);
QWebPage::ErrorPageExtensionReturn* errorPage = static_cast<QWebPage::ErrorPageExtensionReturn*>(output);
errorPage
->content
= QString("<html><head><title>Failed loading page</title></head><body>%1</body></html>").
arg(info
->errorString
).
toUtf8();
return true;
}
Added after 28 minutes:
now it works perfect, thanks very much!!! the problem is solved
Re: webview custom error pages
You should check the type of extension being handled before casting and using the parameters.
Re: webview custom error pages