[Qt] QWebKit and loading pages
Marcin Dębicki
alterfenix at gmail.com
Mon Nov 9 02:38:09 CET 2009
I use to load pages with QWebView:
if (Pos('://', URL)=0) and (not FileExists(URL)) then
w:='http://'+URL else
w:=URL;
fUrl:=QUrl_create(@w, QUrlTolerantMode);
QWebView_setUrl(Handle,fUrl);
QUrl_Destroy(fUrl);
object constructor:
constructor TWebView.Create(Parent : TWinControl; URL: string;
aNetworkAccessManager: QNetworkAccessManagerH; SetEditable: boolean =
false);
var
W : WideString;
begin
Handle := QWebView_create(L2Qt(Parent));
QWebPage:=QLCLWebPage_create(TQtWidget(Parent).Widget);
QWebView_setPage(Handle,QWebPage);
QWebPage_setContentEditable(QWebPage, SetEditable);
NetworkAccessManager:=aNetworkAccessManager;//QWebPage_networkAccessManager(QWebPage);
QWebPage_setNetworkAccessManager(QWebPage,aNetworkAccessManager);
QLCLWebPage_override_userAgentForUrl(QWebPage,
@UserAgentForUrl);//TMethod(QLCLWebPage_UserAgentForUrl_Override(@UserAgentForUrl)));
Settings:=QWebPage_settings(QWebPage);
QWebSettings_setAttribute(Settings,QWebSettingsJavascriptEnabled,true);
QWebSettings_setAttribute(Settings,QWebSettingsPluginsEnabled,true);
QWebSettings_setAttribute(Settings,QWebSettingsPrivateBrowsingEnabled,false);
QWebSettings_setAttribute(Settings,QWebSettingsJavascriptCanOpenWindows,true);
w:=URL;
fUrl:=QUrl_create(@w, QUrlTolerantMode);
QWebView_setUrl(Handle,fUrl);
QWidget_resize(Handle, 500, 500);
QUrl_Destroy(fUrl);
QWidget_Show(Handle);
pURL:=URL;
end;
Whenever I call procedure TWebView.LoadURL(URL: string); (first listing)
memory usage of my application increases by more less 5-6 MB, sometimes even
more. With QWebView_load it is the same.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/qt/attachments/20091109/a379371f/attachment-0002.html>
More information about the Qt
mailing list