Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebEngine open links issue
Forum Update on Tuesday, May 27th 2025

QWebEngine open links issue

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 4 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cobra91151
    wrote on 9 Aug 2018, 09:48 last edited by Cobra91151 8 Sept 2018, 09:48
    #1

    Hi! I have noticed that QWebEngine doesn't open some links. For example, when I navigate to https://www.qt.io/, and press on these links, it do nothing.

    0_1533807579327_2018-08-09_123901.png

    But when I open context menu, it displays the default menus, and there is option to follow link, when I clicked on it, the page has been opened successfully.

    0_1533807724276_2018-08-09_124031.png

    Code:

    QWebEngineView *browserTest = new QWebEngineView(this);
    browserTest ->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
    browserTest ->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
    browserTest ->settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, true);
    browserTest ->settings()->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, true);
    browserTest ->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
    browserTest ->settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
    

    So how to open these links by mouse clicks? Why it is not the default behavior to open links in the QWebEngine? Thanks.

    J 1 Reply Last reply 9 Aug 2018, 10:54
    0
    • C Cobra91151
      9 Aug 2018, 09:48

      Hi! I have noticed that QWebEngine doesn't open some links. For example, when I navigate to https://www.qt.io/, and press on these links, it do nothing.

      0_1533807579327_2018-08-09_123901.png

      But when I open context menu, it displays the default menus, and there is option to follow link, when I clicked on it, the page has been opened successfully.

      0_1533807724276_2018-08-09_124031.png

      Code:

      QWebEngineView *browserTest = new QWebEngineView(this);
      browserTest ->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
      browserTest ->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
      browserTest ->settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, true);
      browserTest ->settings()->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, true);
      browserTest ->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
      browserTest ->settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
      

      So how to open these links by mouse clicks? Why it is not the default behavior to open links in the QWebEngine? Thanks.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 9 Aug 2018, 10:54 last edited by
      #2

      @Cobra91151 My guess is that you're missing OpenSSL

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply 9 Aug 2018, 10:59
      1
      • J jsulm
        9 Aug 2018, 10:54

        @Cobra91151 My guess is that you're missing OpenSSL

        C Offline
        C Offline
        Cobra91151
        wrote on 9 Aug 2018, 10:59 last edited by
        #3

        @jsulm

        Hi! What do you mean by missing OpenSSL?

        J 1 Reply Last reply 9 Aug 2018, 11:00
        0
        • C Cobra91151
          9 Aug 2018, 10:59

          @jsulm

          Hi! What do you mean by missing OpenSSL?

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 9 Aug 2018, 11:00 last edited by
          #4

          @Cobra91151 You're trying to access HTTPS URLs which are encrypted.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply 9 Aug 2018, 11:05
          0
          • J jsulm
            9 Aug 2018, 11:00

            @Cobra91151 You're trying to access HTTPS URLs which are encrypted.

            C Offline
            C Offline
            Cobra91151
            wrote on 9 Aug 2018, 11:05 last edited by
            #5

            @jsulm

            If OpenSSL is missing when why the Follow link in the context menu works? How to get the access to the source code of the QWebEngine context menu?

            J 1 Reply Last reply 9 Aug 2018, 11:06
            0
            • C Cobra91151
              9 Aug 2018, 11:05

              @jsulm

              If OpenSSL is missing when why the Follow link in the context menu works? How to get the access to the source code of the QWebEngine context menu?

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 9 Aug 2018, 11:06 last edited by
              #6

              @Cobra91151 http://code.qt.io/cgit/qt/qtwebengine.git/

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 1 Reply Last reply 9 Aug 2018, 11:09
              0
              • J jsulm
                9 Aug 2018, 11:06

                @Cobra91151 http://code.qt.io/cgit/qt/qtwebengine.git/

                C Offline
                C Offline
                Cobra91151
                wrote on 9 Aug 2018, 11:09 last edited by
                #7

                @jsulm

                Ok. Thanks. I think the problem is with tabs. These links will open in the new tabs, but I need to open it in the same tab.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Cobra91151
                  wrote on 9 Aug 2018, 13:16 last edited by
                  #8

                  I have found that the issue is with links that have target="_blank" properties. So, I should reimplement QWebEnginePage createWindow method to open such links in the same window.

                  J 1 Reply Last reply 9 Aug 2018, 13:22
                  0
                  • C Cobra91151
                    9 Aug 2018, 13:16

                    I have found that the issue is with links that have target="_blank" properties. So, I should reimplement QWebEnginePage createWindow method to open such links in the same window.

                    J Offline
                    J Offline
                    JonB
                    wrote on 9 Aug 2018, 13:22 last edited by
                    #9

                    @Cobra91151
                    target="_blank" links means open in new window/tab, so why would you want to (re-)implement to open in same window? If anything you need to change the link?

                    C 1 Reply Last reply 9 Aug 2018, 13:33
                    0
                    • J JonB
                      9 Aug 2018, 13:22

                      @Cobra91151
                      target="_blank" links means open in new window/tab, so why would you want to (re-)implement to open in same window? If anything you need to change the link?

                      C Offline
                      C Offline
                      Cobra91151
                      wrote on 9 Aug 2018, 13:33 last edited by Cobra91151 8 Sept 2018, 13:33
                      #10

                      @JonB

                      I know what target="_blank" means, I illustrated it for testing purposes. The problem is with QWebEngine doesn't work with it well, and do nothing when clicking on such link. How can I change such links for every website on the web?

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        Cobra91151
                        wrote on 9 Aug 2018, 14:09 last edited by
                        #11

                        I have fixed it by reimplementing QWebEnginePage.

                        appwebenginepage.cpp

                        QWebEnginePage *AppWebEnginePage::createWindow(QWebEnginePage::WebWindowType)
                        {
                            return this;
                        }
                        

                        And added the page to the QWebEngineView.

                        browserTest = new QWebEngineView(browserTab);
                        AppWebEnginePage *webPage = new AppWebEnginePage();
                        browserTest->setPage(webPage);
                        

                        Now it opens all links in the QWebEngineView window.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          Azeem Shami
                          wrote on 28 Feb 2019, 07:56 last edited by
                          #12

                          Cobra91151 I'm also facing the same problem in Python and PyQt5. How to solve this problem in Python?

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved