本文整理汇总了C++中QWebFrame::evaluateJavaScript方法的典型用法代码示例。如果您正苦于以下问题:C++ QWebFrame::evaluateJavaScript方法的具体用法?C++ QWebFrame::evaluateJavaScript怎么用?C++ QWebFrame::evaluateJavaScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWebFrame
的用法示例。
在下文中一共展示了QWebFrame::evaluateJavaScript方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: frameLoaded
void AssetEditor_Script::frameLoaded(bool ok)
{
QWebFrame* frame = ui->webView->page()->mainFrame();
frame->addToJavaScriptWindowObject("bridge",this);
frame->evaluateJavaScript("editor.setValue(bridge.js_get_script_text())"); //Tell editor to set its text to te script text
frame->evaluateJavaScript("editor.setShowPrintMargin(false);");
frame->evaluateJavaScript("editor.selection.moveCursorFileStart();");
}
示例2: manageCommand
void MainWindow::manageCommand(QString cmdId, QAction* action)
{
QWebFrame* pMainFrame = webView()->page()->mainFrame();
action->setVisible(pMainFrame->evaluateJavaScript(
QString::fromAscii("window.desktopHooks.isCommandVisible('") + cmdId + QString::fromAscii("')")).toBool());
action->setEnabled(pMainFrame->evaluateJavaScript(
QString::fromAscii("window.desktopHooks.isCommandEnabled('") + cmdId + QString::fromAscii("')")).toBool());
action->setText(pMainFrame->evaluateJavaScript(
QString::fromAscii("window.desktopHooks.getCommandLabel('") + cmdId + QString::fromAscii("')")).toString());
}
示例3: loadFinished
/**
* Called when the webview finished loading a new page
*/
void PhoneGap::loadFinished( bool ok ) {
Q_UNUSED(ok)
// Change into the xml-directory
QDir xmlDir( m_workingDir );
xmlDir.cd( "xml" );
// Try to open the plugins configuration
QFile pluginsXml( xmlDir.filePath("plugins.xml") );
if( !pluginsXml.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
qDebug() << "Error loading plugins config!";
return;
}
// Start reading the file as a stream
QXmlStreamReader plugins;
plugins.setDevice( &pluginsXml );
// Get a reference to the current main-frame
QWebFrame *webFrame = m_webView->page()->mainFrame();
// Iterate over plugins-configuration and load all according plugins
while(!plugins.atEnd()) {
if( plugins.readNext() == QXmlStreamReader::StartElement ) {
// Check if we have a plugin element
if( plugins.name() == "plugin" ) {
QXmlStreamAttributes attribs = plugins.attributes();
// Check for name & value attributes
if( attribs.hasAttribute("name") && attribs.hasAttribute("value") ) {
// Construct object & attribute names
QString attribName = attribs.value( "name" ).toString();
QString attribValue = attribs.value( "value" ).toString();
QString objectName = attribName + "_native";
qDebug() << "Adding Plugin " << attribName << " with " << attribValue;
// Check for such a plugin
PGPlugin *currPlugin = PluginRegistry::getRegistry()->getPlugin( attribValue );
if( currPlugin != NULL ) {
currPlugin->setWebFrame( webFrame );
webFrame->addToJavaScriptWindowObject( objectName, currPlugin );
webFrame->evaluateJavaScript( "PhoneGap.Qt.registerObject( '" + attribValue + "', " + objectName + " )" );
webFrame->evaluateJavaScript( "PhoneGap.enablePlugin( '" + attribValue + "' )" );
}
else {
qDebug() << "Unknown Plugin " << attribName;
}
}
}
}
}
// Device is now ready to rumble
webFrame->evaluateJavaScript( "PhoneGap.deviceready();" );
}
示例4: finishLoading
/**
* When file finished, execute JavaScript functions
*/
void Qasmine::finishLoading(bool isFinished)
{
if (!isFinished) {
this->log("ERROR: cannot load file : '" + fileName + "'");
exitConditionally(255);
}
QWebFrame *frame = webView->page()->mainFrame();
frame->evaluateJavaScript(readFileContent(":/qasmine.js"));
frame->addToJavaScriptWindowObject(QString("qasmine"), this);
frame->evaluateJavaScript(getQasmineJsCommand());
}
示例5: setVarioList
void WebMapFlight::setVarioList(const FlightPointList::VarioListType &varioList,
uint begin, uint end)
{
QString code = "fl_setVario([%1]);";
QWebFrame *pFrame;
QString value = "%1";
QString strVario = "";
uint itemNr;
uint listSize;
bool first = true;
listSize = std::min((uint)varioList.size(), end);
if(listSize > 0)
{
for(itemNr=begin; itemNr<listSize; itemNr++)
{
if(!first)
{
strVario += ",";
}
first = false;
// sog
strVario += value.arg(round(varioList.at(itemNr) * 10.0) / 10.0);
}
pFrame = m_pWebMap->page()->mainFrame();
pFrame->evaluateJavaScript(code.arg(strVario));
}
}
示例6: setPhotoList
void WebMapFlight::setPhotoList(const Photo::PhotoListType &photoList)
{
QString code = "fl_pushPhoto({lat: %1, lng: %2, path: '%3'});";
QWebFrame *pFrame;
uint listSize;
uint itemNr;
QString path;
double lat;
double lon;
listSize = photoList.size();
if(listSize > 0)
{
pFrame = m_pWebMap->page()->mainFrame();
for(itemNr=0; itemNr<listSize; itemNr++)
{
lat = photoList.at(itemNr).pos().lat();
lon = photoList.at(itemNr).pos().lon();
path = photoList.at(itemNr).path();
pFrame->evaluateJavaScript(code.arg(lat).arg(lon).arg(path));
}
}
}
示例7: setGraphPosition
void MainWindow::setGraphPosition(float lon, float lat)
{
qDebug()<<lon<<lat;
QWebFrame *frame = ui->webView_map->page()->mainFrame();
QString method = QString("SetPosition(%1,%2)").arg(lon).arg(lat);
frame->evaluateJavaScript(method);
}
示例8: getSumatraPdfExePath
QString MainWindow::getSumatraPdfExePath()
{
QWebFrame* pMainFrame = webView()->page()->mainFrame();
QString sumatraPath = pMainFrame->evaluateJavaScript(QString::fromAscii(
"window.desktopHooks.getSumatraPdfExePath()")).toString();
return sumatraPath;
}
示例9: queryCommandState
bool HtmlEditor::queryCommandState(const QString &cmd)
{
QWebFrame *frame = ui->webView->page()->mainFrame();
QString js = QString("document.queryCommandState(\"%1\", false, null)").arg(cmd);
QVariant result = frame->evaluateJavaScript(js);
return result.toString().simplified().toLower() == "true";
}
示例10: request
QObject *CSVFactory::create(const QString &mimeType, const QUrl &url,
const QStringList &argumentNames,
const QStringList &argumentValues) const
{
if (mimeType != "text/csv")
return 0;
QHash<QString, QString> arguments;
for (int i = 0; i < argumentNames.count(); ++i)
arguments[argumentNames[i]] = argumentValues[i];
CSVView *view = new CSVView(arguments["type"], arguments["related"]);
QWebFrame *frame = webView->page()->mainFrame();
frame->addToJavaScriptWindowObject(arguments["related"] + "_input", view);
frame->evaluateJavaScript(
arguments["related"] + "_input.rowSelected.connect(fillInForm);\n");
QNetworkRequest request(url);
QNetworkReply *reply = manager->get(request);
connect(reply, SIGNAL(finished()), view, SLOT(updateModel()));
connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
return view;
}
示例11: installedPlugins
void tst_QWebPluginDatabase::installedPlugins()
{
QWebPage page;
page.settings()->setAttribute(QWebSettings::PluginsEnabled, true);
QWebFrame* frame = page.mainFrame();
QVariantMap jsPluginsMap = frame->evaluateJavaScript("window.navigator.plugins").toMap();
QList<QWebPluginInfo> plugins = QWebSettings::pluginDatabase()->plugins();
QCOMPARE(plugins, QWebSettings::pluginDatabase()->plugins());
int length = jsPluginsMap["length"].toInt();
QCOMPARE(length, plugins.count());
for (int i = 0; i < length; ++i) {
QWebPluginInfo plugin = plugins.at(i);
QVariantMap jsPlugin = frame->evaluateJavaScript(QString("window.navigator.plugins[%1]").arg(i)).toMap();
QString name = jsPlugin["name"].toString();
QString description = jsPlugin["description"].toString();
QString fileName = jsPlugin["filename"].toString();
QCOMPARE(plugin.name(), name);
QCOMPARE(plugin.description(), description);
QCOMPARE(QFileInfo(plugin.path()).fileName(), fileName);
QList<MimeType> mimeTypes;
int mimeTypesCount = jsPlugin["length"].toInt();
for (int j = 0; j < mimeTypesCount; ++j) {
QVariantMap jsMimeType = frame->evaluateJavaScript(QString("window.navigator.plugins[%1][%2]").arg(i).arg(j)).toMap();
MimeType mimeType;
mimeType.name = jsMimeType["type"].toString();
mimeType.description = jsMimeType["description"].toString();
mimeType.fileExtensions = jsMimeType["suffixes"].toString().split(',', QString::SkipEmptyParts);
mimeTypes.append(mimeType);
QVERIFY(plugin.supportsMimeType(mimeType.name));
}
QCOMPARE(plugin.mimeTypes(), mimeTypes);
QVERIFY(!plugin.isNull());
QVERIFY(plugin.isEnabled());
}
}
示例12: evaluateJavaScript
// Public slots.
QVariant QWebFrameProto::evaluateJavaScript(const QString& scriptSource)
{
scriptDeprecated("QWebFrame will not be available in future versions");
QWebFrame *item = qscriptvalue_cast<QWebFrame*>(thisObject());
if (item)
return item->evaluateJavaScript(scriptSource);
return QVariant();
}
示例13: init
void WebMapFlight::init()
{
QString code = "fl_init();";
QWebFrame *pFrame;
pFrame = m_pWebMap->page()->mainFrame();
pFrame->evaluateJavaScript(code);
}
示例14: evaluateSelection
void HelpBrowser::evaluateSelection()
{
static const QString javaScript("selectLine()");
QWebFrame *frame = mWebView->page()->currentFrame();
if( frame ) frame->evaluateJavaScript( javaScript );
QString code( mWebView->selectedText() );
if (!code.isEmpty())
Main::scProcess()->evaluateCode(code);
}
示例15: showPlot
void WebMapFlight::showPlot()
{
QString code = "fl_showPlot();";
QWebFrame *pFrame;
if(m_plotEn)
{
pFrame = m_pWebMap->page()->mainFrame();
pFrame->evaluateJavaScript(code);
}
}