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. How to subclass a QWebEngineView?

How to subclass a QWebEngineView?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 362 Views
  • 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.
  • K Offline
    K Offline
    Kattia
    wrote on last edited by
    #1

    I'm creating a QWebEngineView on Qt Designer, when i right click on it and click on "Promoted widgets...", its missing the option QWebEngineView in the Base class name dropdown.

    Its not possible to subclass from the Qt Designer or is it missing the QWebEngineView?

    I'm testing on Qt 6.6.0/Windows

    Christian EhrlicherC 1 Reply Last reply
    0
    • K Kattia

      I'm creating a QWebEngineView on Qt Designer, when i right click on it and click on "Promoted widgets...", its missing the option QWebEngineView in the Base class name dropdown.

      Its not possible to subclass from the Qt Designer or is it missing the QWebEngineView?

      I'm testing on Qt 6.6.0/Windows

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Select the QWebEngineView from the toolbox and place it in the layout. Then right-click on it and select 'Promote to': https://doc.qt.io/qt-6/designer-using-custom-widgets.html

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      K 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        Select the QWebEngineView from the toolbox and place it in the layout. Then right-click on it and select 'Promote to': https://doc.qt.io/qt-6/designer-using-custom-widgets.html

        K Offline
        K Offline
        Kattia
        wrote on last edited by Kattia
        #3

        @Christian-Ehrlicher its missing the QWebEngineView in the base class.

        Christian EhrlicherC 1 Reply Last reply
        0
        • K Kattia

          @Christian-Ehrlicher its missing the QWebEngineView in the base class.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by Christian Ehrlicher
          #4

          Please do what I wrote. Add a QWebEngineView to your layout, right click on that widget and select 'Promote to'

          /Edit: Strange - after a restart I don't have it there too. The only thing I would do is to modify the xml file directly. Add a promote, use QWidget as base class. Close the editor and open the xml file in a text editor. Then modify the section (at the end) where your widget gets promoted to use QWebEngineView as base class.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          K 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            Please do what I wrote. Add a QWebEngineView to your layout, right click on that widget and select 'Promote to'

            /Edit: Strange - after a restart I don't have it there too. The only thing I would do is to modify the xml file directly. Add a promote, use QWidget as base class. Close the editor and open the xml file in a text editor. Then modify the section (at the end) where your widget gets promoted to use QWebEngineView as base class.

            K Offline
            K Offline
            Kattia
            wrote on last edited by Kattia
            #5

            @Christian-Ehrlicher said in How to subclass a QWebEngineView?:

            Please do what I wrote. Add a QWebEngineView to your layout, right click on that widget and select 'Promote to'

            /Edit: Strange - after a restart I don't have it there too. The only thing I would do is to modify the xml file directly. Add a promote, use QWidget as base class. Close the editor and open the xml file in a text editor. Then modify the section (at the end) where your widget gets promoted to use QWebEngineView as base class.

            Editing the xml, i would need to do it whenever i recompile the ui.

            As a workaround, I have modified the source here:

            https://github.com/qt/qttools/blob/0338a2f7523e1fe21be325e76f6aba6b0c9e4467/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp#L70

            // <MOD>
            QStringList base = baseClasses;
            base.append("QWebEngineView"_L1); 
            //m_baseClassCombo->addItems(baseClasses);
            m_baseClassCombo->addItems(base);
            // </MOD>
            

            baseClasses is const, so i created another QStringList and append the view, now i'm able to promote it.

            B 1 Reply Last reply
            0
            • K Kattia

              @Christian-Ehrlicher said in How to subclass a QWebEngineView?:

              Please do what I wrote. Add a QWebEngineView to your layout, right click on that widget and select 'Promote to'

              /Edit: Strange - after a restart I don't have it there too. The only thing I would do is to modify the xml file directly. Add a promote, use QWidget as base class. Close the editor and open the xml file in a text editor. Then modify the section (at the end) where your widget gets promoted to use QWebEngineView as base class.

              Editing the xml, i would need to do it whenever i recompile the ui.

              As a workaround, I have modified the source here:

              https://github.com/qt/qttools/blob/0338a2f7523e1fe21be325e76f6aba6b0c9e4467/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp#L70

              // <MOD>
              QStringList base = baseClasses;
              base.append("QWebEngineView"_L1); 
              //m_baseClassCombo->addItems(baseClasses);
              m_baseClassCombo->addItems(base);
              // </MOD>
              

              baseClasses is const, so i created another QStringList and append the view, now i'm able to promote it.

              B Offline
              B Offline
              Bonnie
              wrote on last edited by Bonnie
              #6

              @Kattia You don't need to modify the source.
              Just use QWidget as base class in the designer and add a QWidget then promote it. It will work although it doesn't look like a QWebEngineView when designing.
              You will not be able to set the QWebEngineView only properties in the designer, but there're just two of them and can be set in the code. So not a problem.

              1 Reply Last reply
              1

              • Login

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