本文整理汇总了C++中QWebEngineView::setGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebEngineView::setGeometry方法的具体用法?C++ QWebEngineView::setGeometry怎么用?C++ QWebEngineView::setGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebEngineView
的用法示例。
在下文中一共展示了QWebEngineView::setGeometry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processCommand
void CommandHandler::processCommand(const Command &command) const
{
QWebEngineView *webView = ElectricWebView::instance()->webView();
if (command.name() == "load") {
if (command.arguments().isEmpty())
webView->load(QUrl("about:blank"));
else
webView->load(QUrl(command.arguments().first()));
} else if (command.name() == "stop") {
webView->stop();
} else if (command.name() == "reload") {
webView->reload();
} else if (command.name() == "back") {
webView->back();
} else if (command.name() == "forward") {
webView->forward();
} else if (command.name() == "open") {
QString mode = command.arguments().value(0);
if (mode == "maximized") {
webView->showMaximized();
} else if (mode == "fullscreen") {
webView->setGeometry(qApp->desktop()->screenGeometry());
webView->showFullScreen();
}
} else if (command.name() == "close") {
webView->close();
} else if (command.name() == "current_url") {
command.sendResponse(webView->url().toString().toLocal8Bit());
} else if (command.name() == "set_html") {
QString type = command.arguments().value(0);
QString value = command.arguments().mid(1, -1).join(' ');
if (type == "string") {
webView->page()->setHtml(value.toLocal8Bit());
} else if (type == "file") {
QFile file(value);
file.open(QFile::ReadOnly);
webView->page()->setHtml(file.readAll());
}
} else if (command.name() == "get_html") {
QString format = command.arguments().value(0);
QEventLoop loop;
if (format == "html") {
webView->page()->toHtml([&command, &loop](const QString &html) {
if (!command.client().isNull()) {
command.sendResponse(QUrl::toPercentEncoding(html));
if (command.isGetter())
command.client()->close();
}
loop.quit();
});
} else if (format == "text") {
webView->page()->toPlainText([&command, &loop](const QString &text) {
if (!command.client().isNull()) {
command.sendResponse(QUrl::toPercentEncoding(text));
if (command.isGetter())
command.client()->close();
}
loop.quit();
});
} else {
return;
}
loop.exec();
} else if (command.name() == "current_title") {
command.sendResponse(webView->title().toLocal8Bit());
} else if (command.name() == "screenshot") {
processScreenshotCommand(command);
} else if (command.name() == "subscribe") {
QString eventName = command.arguments().value(0);
QStringList events = QStringList()
<< "title_changed"
<< "url_changed"
<< "load_started"
<< "load_finished"
<< "user_activity"
<< "info_message_raised"
<< "warning_message_raised"
<< "error_message_raised"
<< "feature_permission_requested";
if (events.contains(eventName)) {
Event event(command);
event.setName(eventName);
ElectricWebView::instance()->eventManager()->subscribe(event);
}
} else if (command.name() == "exec_js") {
processJavaScriptCommand(command);
} else if (command.name() == "inject_js") {
QMap<QString, QWebEngineScript::ScriptWorldId> worlds;
worlds["main"] = QWebEngineScript::MainWorld;
//.........这里部分代码省略.........