How to subclass a QWebEngineView?
-
I'm creating a
QWebEngineView
on Qt Designer, when i right click on it and click on "Promoted widgets..."
, its missing the optionQWebEngineView
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
-
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
-
@Christian-Ehrlicher its missing the QWebEngineView in the base class.
-
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.
-
@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:
// <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. -
@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.