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. Opening a URL in a widget using QTWebEngineView
Forum Updated to NodeBB v4.3 + New Features

Opening a URL in a widget using QTWebEngineView

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.4k 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.
  • J Offline
    J Offline
    James Sprinks
    wrote on 17 Apr 2018, 16:17 last edited by
    #1

    Hi All

    I want to open up a webpage, but display it in a widget other than centralWidget, how do I do this?

    My code:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QUrl>
    #include <QWebEngineView>
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        view = new QWebEngineView(this);
        connect(ui->web, SIGNAL(clicked(bool)),this,SLOT(webclick()));
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::webclick()
    {
        QUrl site("http://www.gogle.co.uk");
        view->load(site);
    }
    

    i have a a widget labelled ui->screen in which I want to display the website.

    Ta

    J

    V 1 Reply Last reply 17 Apr 2018, 16:24
    0
    • J James Sprinks
      17 Apr 2018, 16:17

      Hi All

      I want to open up a webpage, but display it in a widget other than centralWidget, how do I do this?

      My code:

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      #include <QUrl>
      #include <QWebEngineView>
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
          view = new QWebEngineView(this);
          connect(ui->web, SIGNAL(clicked(bool)),this,SLOT(webclick()));
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      void MainWindow::webclick()
      {
          QUrl site("http://www.gogle.co.uk");
          view->load(site);
      }
      

      i have a a widget labelled ui->screen in which I want to display the website.

      Ta

      J

      V Offline
      V Offline
      VRonin
      wrote on 17 Apr 2018, 16:24 last edited by
      #2

      @James-Sprinks said in Opening a URL in a widget using QTWebEngineView:

      ui->screen in which I want to display the website.

      You have to add a layout to that widget (call it screenLayout then from the constructor call ui->screenLayout->addWidget(view);

      or, if you want ui->screen to become the view then remove view altogether, right click on ui->screen in designer and promote to QWebEngineView then directly call ui->screen->load(site)

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      J 1 Reply Last reply 17 Apr 2018, 16:32
      1
      • V VRonin
        17 Apr 2018, 16:24

        @James-Sprinks said in Opening a URL in a widget using QTWebEngineView:

        ui->screen in which I want to display the website.

        You have to add a layout to that widget (call it screenLayout then from the constructor call ui->screenLayout->addWidget(view);

        or, if you want ui->screen to become the view then remove view altogether, right click on ui->screen in designer and promote to QWebEngineView then directly call ui->screen->load(site)

        J Offline
        J Offline
        James Sprinks
        wrote on 17 Apr 2018, 16:32 last edited by
        #3

        @VRonin Hoq do I add a layout?

        Also, it will not let me promote the widget to QtWebEngineView....

        J

        V 1 Reply Last reply 17 Apr 2018, 16:33
        0
        • J James Sprinks
          17 Apr 2018, 16:32

          @VRonin Hoq do I add a layout?

          Also, it will not let me promote the widget to QtWebEngineView....

          J

          V Offline
          V Offline
          VRonin
          wrote on 17 Apr 2018, 16:33 last edited by VRonin
          #4

          @James-Sprinks said in Opening a URL in a widget using QTWebEngineView:

          Hoq do I add a layout?

          right click on the widget->layout

          it will not let me promote the widget to QWebEngineView

          0_1523982976666_Capture.PNG

          then add, select it and click promote

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          J 1 Reply Last reply 17 Apr 2018, 16:34
          2
          • V VRonin
            17 Apr 2018, 16:33

            @James-Sprinks said in Opening a URL in a widget using QTWebEngineView:

            Hoq do I add a layout?

            right click on the widget->layout

            it will not let me promote the widget to QWebEngineView

            0_1523982976666_Capture.PNG

            then add, select it and click promote

            J Offline
            J Offline
            James Sprinks
            wrote on 17 Apr 2018, 16:34 last edited by
            #5

            @VRonin All I can do is change the size...

            V 1 Reply Last reply 17 Apr 2018, 16:38
            0
            • J James Sprinks
              17 Apr 2018, 16:34

              @VRonin All I can do is change the size...

              V Offline
              V Offline
              VRonin
              wrote on 17 Apr 2018, 16:38 last edited by
              #6

              @James-Sprinks said in Opening a URL in a widget using QTWebEngineView:

              All I can do is change the size...

              0_1523983106894_Capture.PNG

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              3

              1/6

              17 Apr 2018, 16:17

              • Login

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