Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

[[qanda:topic_unsolved]] How to add widgets to QWebEngineView?

$
0
0

Hi,
I.am customizing a web browser,
but when I want to add some widgets to my QWebENgineVIew,
I have to resize the widget every time before it shows.


MyWebEngineView::MyWebEngineView(*parent) : QWebEngineView(parent)
{
	QVBoxLayout* layout = qobject_cast<QVBoxLayout*>(this->layout());
	qDebug() << layout;
	if (nullptr == layout) {
		layout = new QVBoxLayout(this);
	}
	layout->setSpacing(0);
	QToolBar* toolBar = createToolBar();
	layout->addWidget(toolBar);
	progressBar = new QProgressBar(this);
	progressBar->setMaximumHeight(1);
	progressBar->setTextVisible(false);
	progressBar->setStyleSheet(QStringLiteral("QProgressBar {border: 0px} QProgressBar::chunk {background-color: #da4453}"));
	layout->addWidget(progressBar);

	this->extendToolWidget = new QWidget(this);
	this->extendToolWidget->hide();
	layout->addWidget(this->extendToolWidget);
}
    MyWebView *webView = new MyWebView;
    MyWebPage *webPage = new MyWebPage(QWebEngineProfile::defaultProfile(), webView);
    webView->setPage(webPage);

    setupView(webView);
    webView->resize(currentWidget()->size());
    webView->show();

and when I show this widget , I can see my tool bar move from center to top, rather than always on the top.

so what can i do to make my tool ba stay on the top, Thank you.


Viewing all articles
Browse latest Browse all 13965

Trending Articles