本文整理汇总了C++中QScriptEngineDebugger::action方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptEngineDebugger::action方法的具体用法?C++ QScriptEngineDebugger::action怎么用?C++ QScriptEngineDebugger::action使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptEngineDebugger
的用法示例。
在下文中一共展示了QScriptEngineDebugger::action方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// Perhaps shpw entire example for getting debugger up with script
int main(int argv, char **args)
{
QApplication app(argv, args);
QString fileName("helloscript.qs");
QFile scriptFile(fileName);
scriptFile.open(QIODevice::ReadOnly);
QTextStream stream(&scriptFile);
QString contents = stream.readAll();
scriptFile.close();
QScriptEngine *engine = new QScriptEngine();
QScriptEngineDebugger *debugger = new QScriptEngineDebugger();
debugger->attachTo(engine);
// Set up configuration with only stack and code
QWidget *widget = new QWidget;
//![0]
QWidget *codeWindow = debugger->widget(QScriptEngineDebugger::CodeWidget);
QWidget *stackWidget = debugger->widget(QScriptEngineDebugger::StackWidget);
QLayout *layout = new QHBoxLayout;
layout->addWidget(codeWindow);
layout->addWidget(stackWidget);
//![0]
//![1]
QAction *continueAction = debugger->action(QScriptEngineDebugger::ContinueAction);
QAction *stepOverAction = debugger->action(QScriptEngineDebugger::StepOverAction);
QAction *stepIntoAction = debugger->action(QScriptEngineDebugger::StepIntoAction);
QToolBar *toolBar = new QToolBar;
toolBar->addAction(continueAction);
//![1]
toolBar->addAction(stepOverAction);
toolBar->addAction(stepIntoAction);
layout->addWidget(toolBar);
continueAction->setIcon(QIcon("copy.png"));
debugger->setAutoShowStandardWindow(false);
widget->setLayout(layout);
widget->show();
QPushButton button;
QScriptValue scriptButton = engine->newQObject(&button);
engine->globalObject().setProperty("button", scriptButton);
//![2]
debugger->action(QScriptEngineDebugger::InterruptAction)->trigger();
engine->evaluate(contents, fileName);
//![2]
return app.exec();
}
示例2: execute
bool execute()
{
TFilePath fp;
QString fileName = "helloworld.qs";
QFile scriptFile(QString::fromStdWString(fp.getWideString()));
if (!scriptFile.open(QIODevice::ReadOnly)) {
DVGui::MsgBox(DVGui::WARNING, QObject::tr("File not found"));
return false;
} else {
QTextStream stream(&scriptFile);
QString contents = stream.readAll();
scriptFile.close();
QScriptEngine myEngine;
QScriptEngineDebugger debugger;
debugger.attachTo(&myEngine);
QScriptValue fFoo = myEngine.newFunction(foo);
QScriptValue fGetLevel = myEngine.newFunction(getLevel);
myEngine.globalObject().setProperty("foo", fFoo);
myEngine.globalObject().setProperty("getLevel", fGetLevel);
debugger.action(QScriptEngineDebugger::InterruptAction)->trigger();
myEngine.evaluate(contents, fileName);
}
return true;
}
示例3: runScript
bool QtScriptEngine::runScript(const QString& script, const QString& name, RunMode mode)
{
MyQScriptEngine engine(this);
map<ADM_dynMuxer*, Muxer*> muxers;
map<ADM_videoEncoder6*, VideoEncoder*> videoEncoders;
#ifdef QT_SCRIPTTOOLS
QScriptEngineDebugger debugger;
if (mode == IScriptEngine::Debug || mode == IScriptEngine::DebugOnError)
{
debugger.attachTo(&engine);
debugger.standardWindow()->setWindowTitle(QT_TR_NOOP("Avidemux Script Debugger"));
debugger.standardWindow()->setWindowModality(Qt::ApplicationModal);
if (mode == IScriptEngine::Debug)
{
debugger.action(QScriptEngineDebugger::InterruptAction)->trigger();
}
}
#endif
this->registerAudioEncoderPlugins(&engine);
this->registerMuxerPlugins(&engine, &muxers);
this->registerVideoEncoderPlugins(&engine, &videoEncoders);
this->registerVideoFilterPlugins(&engine);
this->registerDialogClasses(&engine);
this->registerScriptClasses(&engine, &muxers, &videoEncoders);
QScriptValue result = engine.evaluate(script, name);
bool success = false;
if (engine.hasUncaughtException())
{
QString errorDetails = (QString("Unable to process script.\n\nLine number: %1\n").arg(
engine.uncaughtExceptionLineNumber()) + result.toString());
this->callEventHandlers(IScriptEngine::Error, NULL, -1, (QString("Script error ") + errorDetails).toUtf8().constData());
success = false;
}
else
{
this->callEventHandlers(IScriptEngine::Information, NULL, -1, (QString("Result: ") + result.toString()).toUtf8().constData());
success = true;
}
return success;
}
示例4: action
void tst_QScriptEngineDebugger::action()
{
#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600
QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll);
#endif
QScriptEngine engine;
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
QList<QScriptEngineDebugger::DebuggerAction> actions;
actions
<< QScriptEngineDebugger::InterruptAction
<< QScriptEngineDebugger::ContinueAction
<< QScriptEngineDebugger::StepIntoAction
<< QScriptEngineDebugger::StepOverAction
<< QScriptEngineDebugger::StepOutAction
<< QScriptEngineDebugger::RunToCursorAction
<< QScriptEngineDebugger::RunToNewScriptAction
<< QScriptEngineDebugger::ToggleBreakpointAction
<< QScriptEngineDebugger::ClearDebugOutputAction
<< QScriptEngineDebugger::ClearErrorLogAction
<< QScriptEngineDebugger::ClearConsoleAction
<< QScriptEngineDebugger::FindInScriptAction
<< QScriptEngineDebugger::FindNextInScriptAction
<< QScriptEngineDebugger::FindPreviousInScriptAction
<< QScriptEngineDebugger::GoToLineAction;
QList<QAction*> lst;
for (int i = 0; i < actions.size(); ++i) {
QScriptEngineDebugger::DebuggerAction da = actions.at(i);
QAction *act = debugger.action(da);
QVERIFY(act != 0);
QCOMPARE(act, debugger.action(da));
QCOMPARE(act->parent(), (QObject*)&debugger);
QVERIFY(lst.indexOf(act) == -1);
lst.append(act);
}
}
示例5: debuggerSignals
void tst_QScriptEngineDebugger::debuggerSignals()
{
#if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600
QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll);
#endif
QScriptEngine engine;
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
debugger.setAutoShowStandardWindow(false);
QSignalSpy evaluationSuspendedSpy(&debugger, SIGNAL(evaluationSuspended()));
QSignalSpy evaluationResumedSpy(&debugger, SIGNAL(evaluationResumed()));
QObject::connect(&debugger, SIGNAL(evaluationSuspended()),
debugger.action(QScriptEngineDebugger::ContinueAction),
SLOT(trigger()));
engine.evaluate("123");
QCOMPARE(evaluationSuspendedSpy.count(), 0);
QCOMPARE(evaluationResumedSpy.count(), 0);
engine.evaluate("debugger");
QCoreApplication::processEvents();
QCOMPARE(evaluationSuspendedSpy.count(), 1);
QCOMPARE(evaluationResumedSpy.count(), 1);
}