1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
m_view = new QWebEngineView(parent);
connect(m_view, SIGNAL(loadStarted()), this, SLOT(LoadStarted()));
connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(LoadProgress(int)));
connect(m_view, SIGNAL(loadFinished(bool)), this, SLOT(LoadFinished(bool)));
QUrl url= QUrl::fromLocalFile("C:/Users/index_1.html");
if (!url.isValid()){
qDebug("Invalid URL: %s", qUtf8Printable(url.toString()));
}
else qDebug("Valid URL: %s", qUtf8Printable(url.toString()));
m_view->load(url);
QWidget *widget = new QWidget(this);
widget->setGeometry(QRect(0,0,m_view->width(), m_view->height()));
widget->setContentsMargins(0,0,0,0);
widget->setStyleSheet("padding:0px;""margin:0px;""border-width:1px;""background-color:red;""border-color:black;");
QVBoxLayout *layout = new QVBoxLayout(widget);
layout->setSizeConstraint(QLayout::SetFixedSize);
layout->setGeometry(QRect(0,0,m_view->width(), m_view->height()));
layout->setSpacing(0);
layout->setContentsMargins(0,0,0,0);
layout->addWidget(m_view, 0, Qt::AlignCenter);
widget->setLayout(layout);
widget->show(); |
Partager