QtCreator 4.1.0 dosn't show webengineview(QT 5

2019-07-28 19:55发布

问题:

I'm porting my app from QT 5.5 to QT 5.7. So I need to change WebKit to QWebeEngine, but I can't find QWebEngineView from Widget browser in Visual editor. How I get the QWebEngineView to Widget list.

I have added QT += webenginewidgets to PRO file but it dosen't show the widgets.

回答1:

Do you need the QWebEngineView in the Widget palette for any specific reason? You can use any of the web engine widgets directly from code (although it is of course not as simple as a drag-and-drop). As a simple example:

#include <QWebEngineView>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QString url = "https://stackoverflow.com/";
    QWebEngineView view = new QWebEngineView(this);
    view->load(url);
    // Sets the webview to be the main window's central widget.
    setCentralWidget(view);
}

Not sure if this helps you in any way. If you are really interested in having the widget in the designer, you can maybe try adding it as a custom module. Have a look at the following links:

  • http://doc.qt.io/qt-5.7/designer-using-custom-widgets.html
  • http://www.ics.com/blog/integrating-custom-widget-qt-designer