本文整理汇总了C++中WebView::setUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ WebView::setUrl方法的具体用法?C++ WebView::setUrl怎么用?C++ WebView::setUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebView
的用法示例。
在下文中一共展示了WebView::setUrl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
BrowserApplication application(argc, argv);
QCoreApplication::setApplicationName(QLatin1String("urllineeditexample"));
QMainWindow w;
QWidget *window = new QWidget;
QComboBox *comboBox = new QComboBox(window);
comboBox->setEditable(true);
QLineEdit *lineEdit = new QLineEdit(window);
LocationBar *s1 = new LocationBar(window);
LocationBar *s2 = new LocationBar(window);
WebView *view = new WebView(window);
view->setUrl(QUrl("http://www.google.com"));
s2->setWebView(view);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(comboBox);
layout->addWidget(lineEdit);
layout->addWidget(s1);
layout->addWidget(s2);
layout->addWidget(view);
window->setLayout(layout);
w.show();
w.setCentralWidget(window);
QToolBar *bar = w.addToolBar("foo");
QSplitter *splitter = new QSplitter(window);
splitter->addWidget(new LocationBar);
splitter->addWidget(new QLineEdit);
bar->addWidget(splitter);
return application.exec();
}
示例2: onLoadingChanged
void WebViewRecipe::onLoadingChanged(bb::cascades::WebLoadRequest *loadRequest)
{
if (loadRequest->status() == WebLoadStatus::Started) {
// Show the ProgressBar when navigation is requested.
mLoadingIndicator->setOpacity(1.0);
} else if (loadRequest->status() == WebLoadStatus::Succeeded) {
// The ProgressIndicator is hidden on success or failure.
mLoadingIndicator->setOpacity(0.0);
} else if (loadRequest->status() == WebLoadStatus::Failed) {
WebView *webView = dynamic_cast<WebView*>(sender());
mLoadingIndicator->setOpacity(0.0);
// If loading failed, fallback a local html file which will also send a java script message
QUrl fallbackUrl("local:///assets/WebViewFallback.html");
webView->setUrl(fallbackUrl);
}
}
示例3: QObject
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
QObject(app)
{
// prepare the localization
m_pTranslator = new QTranslator(this);
m_pLocaleHandler = new LocaleHandler(this);
bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
// This is only available in Debug builds
Q_ASSERT(res);
// Since the variable is not used in the app, this is added to avoid a
// compiler warning
Q_UNUSED(res);
// initial load
onSystemLanguageChanged();
// Create scene document from main.qml asset, the parent is set
// to ensure the document gets destroyed properly at shut down.
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("app", this);
// Create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
WebView* wv = root->findChild<WebView*>("oauthWebView");
QString url = "https://www.dropbox.com/1/oauth2/authorize?";
url.append("client_id=").append("<appkey>").append("&");
url.append("response_type=token&");
url.append("redirect_uri=").append("<redirect_uri>").append("&");
url.append("state=").append("<CSRF token>");
wv->setUrl(QUrl(url));
// Set created root object as the application scene
app->setScene(root);
}
示例4: CustomControl
WebViewRecipe::WebViewRecipe(Container *parent) :
CustomControl(parent)
{
bool connectResult;
Q_UNUSED(connectResult);
// Get the UIConfig object in order to use resolution independent sizes.
UIConfig *ui = this->ui();
// The recipe Container
Container *recipeContainer = new Container();
recipeContainer->setLayout(new DockLayout());
WebView *webView = new WebView();
webView->setUrl(QUrl("https://github.com/blackberry/Cascades-Samples/blob/master/cascadescookbookqml/assets/Slider.qml"));
// We let the scroll view scroll in both x and y and enable zooming,
// max and min content zoom property is set in the WebViews onMinContentScaleChanged
// and onMaxContentScaleChanged signal handlers.
mScrollView = ScrollView::create().scrollMode(ScrollMode::Both).pinchToZoomEnabled(true);
mScrollView->setContent(webView);
// Connect to signals to manage the progress indicator.
connectResult = connect(webView, SIGNAL(loadingChanged(bb::cascades::WebLoadRequest *)), this,
SLOT(onLoadingChanged(bb::cascades::WebLoadRequest *)));
Q_ASSERT(connectResult);
connectResult = connect(webView, SIGNAL(loadProgressChanged(int)), this,
SLOT(onProgressChanged(int)));
Q_ASSERT(connectResult);
connectResult = connect(webView, SIGNAL(navigationRequested(bb::cascades::WebNavigationRequest *)), this,
SLOT(onNavigationRequested(bb::cascades::WebNavigationRequest *)));
Q_ASSERT(connectResult);
// Connect signals to manage the web contents suggested size.
connectResult = connect(webView, SIGNAL(maxContentScaleChanged(float)), this,
SLOT(onMaxContentScaleChanged(float)));
Q_ASSERT(connectResult);
connectResult = connect(webView, SIGNAL(minContentScaleChanged(float)), this,
SLOT(onMinContentScaleChanged(float)));
Q_ASSERT(connectResult);
// Connect signal to handle java script calls to navigator.cascades.postMessage()
connectResult = connect(webView, SIGNAL(messageReceived(const QVariantMap&)), this,
SLOT(onMessageReceived(const QVariantMap&)));
Q_ASSERT(connectResult);
WebSettings *settings = webView->settings();
QVariantMap settingsMap;
settingsMap["width"] = QString("device-width");
settingsMap["initial-scale"] = 1.0;
settings->setViewportArguments(settingsMap);
// A progress indicator that is used to show the loading status
Container *progressContainer = Container::create().bottom(ui->du(2));
progressContainer->setLayout(new DockLayout());
progressContainer->setVerticalAlignment(VerticalAlignment::Bottom);
progressContainer->setHorizontalAlignment(HorizontalAlignment::Center);
mLoadingIndicator = ProgressIndicator::create().opacity(0.0);
progressContainer->add(mLoadingIndicator);
// Add the controls and set the root Container of the Custom Control.
recipeContainer->add(mScrollView);
recipeContainer->add(progressContainer);
setRoot(recipeContainer);
}