PDA

View Full Version : Remove content type from supported list



MacAssembly
22nd August 2017, 23:15
I found supportedContentTypes() that returns the list of all content types supported by QWebPage but I'd like to remove a content-type from that list. Is that possible? I read QWebPage documentation and QWebView related functions but found nothing would help so far.

sedi
23rd August 2017, 00:18
Hm. Can't you just subclass QWebPage and overwrite that method?

Something along these lines (absolutely untested and not long thought about)

class MyWebPage: public QWebPage
{
MyWebPage([whatever is needed]) : QWebPage ([whatever is needed]) {}
QStringList MyWebPage::supportedContentTypes() const {
return QWebPage::supportedContentTypes.removeOne("whateverYoWant");
}
}

MacAssembly
23rd August 2017, 03:27
I didn't thought this before even albeit I'm overridng QWebPage already. it would solve, I guess, but supportedContentTypes() isn't a virtual method. :(

sedi
24th August 2017, 00:19
I see two options:
1. Look into QWebPage source if there are any related virtual methods responsible for the generation of that list. I'd doubt it.
2. What element is needing the list? Can you intercept / subclass here?
As you have provided no code I have no idea what you want to achieve.