[Interest] QtWebKit and open URL in new tab window

neel patel neel5481 at gmail.com
Wed Nov 22 10:29:49 CET 2017


Hi Konstantin,



On Tue, Nov 21, 2017 at 2:52 PM, neel patel <neel5481 at gmail.com> wrote:

> Hi,
>
> Yes. By using "_blank" - "createWindow" callback is getting called every
> time we click on link.
> You are right - We should use "_blank" instead of "_new" target attribute
> as didn't find any reference document.
>
> Thanks for your valuable suggestion.
>
> Regards,
> Neel Patel
>
> On Tue, Nov 21, 2017 at 1:57 PM, Konstantin Tokarev <annulen at yandex.ru>
> wrote:
>
>>
>>
>> >> Hi,
>> >>
>> >> I want to create new window in my QTabWidget when we get "target=_new"
>> from HTML file.
>> >>
>> >> We are getting "createWindow" call from Qt when user click on any link
>> with attribute "target=_new" and I am handling that and open in new tab in
>> QTabWidget.
>> >>
>> >> BUT when we close the opened tab and again click on same link then
>> second time i am not getting the "createWindow" call so not able to open in
>> new tab. Any idea why ?
>> >
>> > Use target="_blank" because this is the only way defined in HTML for
>> opening URL in new window each time:
>> >
>> > https://developer.mozilla.org/en-US/docs/Web/HTML/Element/A#attr-target
>> >
>> > Using target="_new" just means that you want the URL to be opened in
>> the frame with name="_new", that's why it behaves
>> > differently.
>>
>> Remaining question is why frame "_new" is not created from scratch after
>> you close tab. This does not reproduce here,
>> and probably you are keeping around corresponding QWebFrame or QWebPage
>> object after tab is closed, or just leak it.
>>
> Yes. you are right. There was no delete of QWebPage while closing the tab
and once i implemented memory free - now signal is coming. Thanks for your
input.

But in QWebEngine also we are getting "createWindow" callback. I have tried
same by deleting QWebEnginePage of QWebEngineView but result is not same as
WebKit. Any pointer I can try ?


>> >
>> >> Below code for reference.
>> >>
>> >> #################################
>> >>
>> >> class MyWebView : public QWebView
>> >>
>> >> {
>> >>
>> >> Q_OBJECT
>> >>
>> >> public:
>> >>
>> >> MyWebView (QWidget *parent = NULL);
>> >>
>> >> private:
>> >>
>> >> QString m_url;
>> >>
>> >> };
>> >>
>> >> class MyWebViewPage : public QWebPage
>> >>
>> >> {
>> >>
>> >> Q_OBJECT
>> >>
>> >> public:
>> >>
>> >> MyWebViewPage (QObject *parent = 0);
>> >>
>> >> ~ MyWebViewPage();
>> >>
>> >> protected:
>> >>
>> >> virtual bool acceptNavigationRequest(QWebFrame *frame, const
>> QNetworkRequest &request, NavigationType type);
>> >>
>> >> QWebPage *createWindow(QWebPage::WebWindowType type);
>> >>
>> >> bool javaScriptConfirm(QWebFrame * frame, const QString & msg);
>> >>
>> >> };
>> >>
>> >> #################################
>> >>
>> >> Can anyone suggest - why "createWindow" is not getting called when we
>> close and open the new tab window ?
>> >>
>> >> Thanks in Advance.
>> >
>> > --
>> > Regards,
>> > Konstantin
>> > _______________________________________________
>> > Interest mailing list
>> > Interest at qt-project.org
>> > http://lists.qt-project.org/mailman/listinfo/interest
>> --
>> Regards,
>> Konstantin
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171122/68772b12/attachment.html>


More information about the Interest mailing list