0

I'm trying to integrate a QWebEngineView widget that runs as a separate process(QProcess) inside a QTabWidget page. So far the QWebEngineView process is being started properly but its showing the webpage in a separate window instead of showing it inside the QTabWidget in the MainWindow application.

This is the Widget that is being added to the QTabWidget.

BrokersTerminal.h



class BrokersTerminal : public QWidget
{
    Q_OBJECT

  public:
    explicit BrokersTerminal(QWidget *parent = 0);
    ~BrokersTerminal();

    void startTerminal();

  public slots:
    void brokersTerminalStarted();

  private:
    Ui::BrokersTerminal *ui;
    QProcess *brokers_process;
    QString brokers_program_path;
    QStringList arguments;
};


BrokersTerminal.cpp

BrokersTerminal::BrokersTerminal(QWidget *parent) :
  QWidget(parent),
  ui(new Ui::BrokersTerminal)
{
  ui->setupUi(this);
  brokers_process = new QProcess( this );
  brokers_program_path = QApplication::applicationFilePath();

  arguments << "--b";

  connect( brokers_process, &QProcess::started, this , &BrokersTerminal::brokersTerminalStarted );
}

BrokersTerminal::~BrokersTerminal()
{
  delete ui;
}

void BrokersTerminal::startTerminal()
{
  brokers_process->start( brokers_program_path, arguments );
  brokers_process->waitForStarted();
}

void BrokersTerminal::brokersTerminalStarted()
{
  qDebug() << "Brokers terminal started";
}

This is the WebView Widget that is responsible for displaying the brokers website.

BrokersWebWidget.h

class BrokersWebWidget : public QWidget
{
    Q_OBJECT

  public:
    explicit BrokersWebWidget(QWidget *parent = 0);
    ~BrokersWebWidget();

  private:
    Ui::BrokersWebWidget *ui;
    QUrl brokers_url;
    QWebEngineView *web_browser;
};

BrokersWebWidget.cpp

BrokersWebWidget::BrokersWebWidget(QWidget *parent) :
  QWidget(parent),
  ui(new Ui::BrokersWebWidget)
{
  ui->setupUi(this);

  brokers_url = "https://siteofbrokersapi.com/";

  web_browser = new QWebEngineView( this );
  web_browser->load( brokers_url );
}

BrokersWebWidget::~BrokersWebWidget()
{
  delete ui;
}

Right now this BrokersWebWidget starts properly as a separate process but it opens in a separate window , but how can this be added in the BrokersTerminal Widget ?

Please let me know of any possible solutions. Thanks.

Simon Warta
  • 10,850
  • 5
  • 40
  • 78
Maxx
  • 592
  • 18
  • 42

1 Answers1

1

You cannot embed a widget running in one process into a window run in another. QWidgets can only work with widgets run in the GUI thread in the same process.

jonspaceharper
  • 4,207
  • 2
  • 22
  • 42
  • Well yes i understand your point that the Widgets needs to be in the same GUI process to be able to be integrated in it. So i changed my design plan to make sure that all the GUI related stuffs are done in the same MainWindow process, while the heavy computations are delegated to the background processes. Thanks for your advice. – Maxx May 10 '16 at 05:35