本文整理汇总了C++中QScriptEngineDebugger类的典型用法代码示例。如果您正苦于以下问题:C++ QScriptEngineDebugger类的具体用法?C++ QScriptEngineDebugger怎么用?C++ QScriptEngineDebugger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QScriptEngineDebugger类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
void tst_QScriptEngineDebugger::widget()
{
#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::DebuggerWidget> widgets;
widgets
<< QScriptEngineDebugger::ConsoleWidget
<< QScriptEngineDebugger::StackWidget
<< QScriptEngineDebugger::ScriptsWidget
<< QScriptEngineDebugger::LocalsWidget
<< QScriptEngineDebugger::CodeWidget
<< QScriptEngineDebugger::CodeFinderWidget
<< QScriptEngineDebugger::BreakpointsWidget
<< QScriptEngineDebugger::DebugOutputWidget
<< QScriptEngineDebugger::ErrorLogWidget;
QList<QWidget*> lst;
for (int i = 0; i < widgets.size(); ++i) {
QScriptEngineDebugger::DebuggerWidget dw = widgets.at(i);
QWidget *wid = debugger.widget(dw);
QVERIFY(wid != 0);
QCOMPARE(wid, debugger.widget(dw));
QVERIFY(lst.indexOf(wid) == -1);
lst.append(wid);
QCOMPARE(static_cast<QWidget *>(wid->parent()), (QWidget*)0);
}
}
示例2: QObject
MapleManager::MapleManager(Server* server, QWidget *widget) :
QObject(server),
m_status(ConnectionStatus::WAITIGN),
m_launch_status(LaunchStatus::LAUNCHIGN),
m_socket(0),
m_relaunch(true),
r_mode(MapleManager::RESIZE_MODE::AUTO)
{
m_server = server;
m_widget = new ManagerWidget(widget);
m_widget->installEventFilter(this);
connect(m_widget,SIGNAL(save()),this,SLOT(saveSettings()));
connect(m_widget,SIGNAL(load()),this,SLOT(loadSettings()));
connect(m_widget,SIGNAL(showDBG(bool)),this,SLOT(showDBG(bool)));
connect(m_widget,SIGNAL(relaunch(bool)),this,SLOT(setRelaunch(bool)));
connect(m_widget,SIGNAL(s_changeTabName(QString)),this,SLOT(changeTabName(QString)));
m_engine = new QScriptEngine(this);
QScriptEngineDebugger *dbg = new QScriptEngineDebugger(this);
dbg->attachTo(m_engine);
m_widget->regiterDebugger((QWidget*)dbg->standardWindow());
ScriptFunctions::registerFuncions(m_engine);
m_engine->globalObject().setProperty(API::Path,qApp->applicationDirPath());
m_engine->globalObject().setProperty(API::GUI,m_engine->newQObject(m_widget));
m_engine->globalObject().setProperty(API::Socket,m_engine->newQObject(this));
}
示例3: 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;
}
示例4: engine
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;
}
示例5: main
int main(int argc, char **argv)
{
Q_INIT_RESOURCE(calculator);
QApplication app(argc, argv);
//! [0a]
QScriptEngine engine;
//! [0a]
#if !defined(QT_NO_SCRIPTTOOLS)
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
QMainWindow *debugWindow = debugger.standardWindow();
debugWindow->resize(1024, 640);
#endif
//! [0b]
QString scriptFileName(":/calculator.js");
QFile scriptFile(scriptFileName);
scriptFile.open(QIODevice::ReadOnly);
engine.evaluate(scriptFile.readAll(), scriptFileName);
scriptFile.close();
//! [0b]
//! [1]
QUiLoader loader;
QFile uiFile(":/calculator.ui");
uiFile.open(QIODevice::ReadOnly);
QWidget *ui = loader.load(&uiFile);
uiFile.close();
//! [1]
//! [2]
QScriptValue ctor = engine.evaluate("Calculator");
QScriptValue scriptUi = engine.newQObject(ui, QScriptEngine::ScriptOwnership);
QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi);
//! [2]
#if !defined(QT_NO_SCRIPTTOOLS)
QLineEdit *display = qFindChild<QLineEdit*>(ui, "display");
QObject::connect(display, SIGNAL(returnPressed()),
debugWindow, SLOT(show()));
#endif
//! [3]
ui->show();
return app.exec();
//! [3]
}
示例6: 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();
}
示例7: PyBool_FromLong
static PyObject *meth_QScriptEngineDebugger_autoShowStandardWindow(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QScriptEngineDebugger *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QScriptEngineDebugger, &sipCpp))
{
bool sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->autoShowStandardWindow();
Py_END_ALLOW_THREADS
return PyBool_FromLong(sipRes);
}
}
示例8: scriptFile
bool JSScript::execute(TWScriptAPI *tw) const
{
QFile scriptFile(m_Filename);
if (!scriptFile.open(QIODevice::ReadOnly)) {
// handle error
return false;
}
QTextStream stream(&scriptFile);
stream.setCodec(m_Codec);
QString contents = stream.readAll();
scriptFile.close();
QScriptEngine engine;
QScriptValue twObject = engine.newQObject(tw);
engine.globalObject().setProperty("TW", twObject);
QScriptValue val;
#if QT_VERSION >= 0x040500
QSETTINGS_OBJECT(settings);
if (settings.value("scriptDebugger", false).toBool()) {
QScriptEngineDebugger debugger;
debugger.attachTo(&engine);
val = engine.evaluate(contents, m_Filename);
}
else {
val = engine.evaluate(contents, m_Filename);
}
#else
val = engine.evaluate(contents, m_Filename);
#endif
if (engine.hasUncaughtException()) {
tw->SetResult(engine.uncaughtException().toString());
return false;
}
else {
if (!val.isUndefined()) {
tw->SetResult(convertValue(val));
}
return true;
}
}
示例9: Py_INCREF
static PyObject *meth_QScriptEngineDebugger_detach(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QScriptEngineDebugger *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QScriptEngineDebugger, &sipCpp))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->detach();
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QScriptEngineDebugger, sipName_detach, doc_QScriptEngineDebugger_detach);
return NULL;
}
示例10: QScriptEngineDebugger
void SmsScriptsManager::init()
{
#if SMS_USE_DEBUGGER
QScriptEngineDebugger *debugger = new QScriptEngineDebugger(this);
debugger->attachTo(Engine);
debugger->standardWindow()->show();
#endif
QString scriptPath = Application::instance()->pathsProvider()->profilePath() + QLatin1String("plugins/data/sms/scripts/gateway.js");
if (QFile::exists(scriptPath))
loadScript(scriptPath);
else
{
scriptPath = Application::instance()->pathsProvider()->dataPath() + QLatin1String("plugins/data/sms/scripts/gateway.js");
if (QFile::exists(scriptPath))
loadScript(scriptPath);
// TODO: maybe we should return here if no gateway.js was found?
}
// scripts from profile path can replace the ones from data path if the file name is the same
loadScripts(QDir(Application::instance()->pathsProvider()->profilePath() + QLatin1String("plugins/data/sms/scripts")));
loadScripts(QDir(Application::instance()->pathsProvider()->dataPath() + QLatin1String("plugins/data/sms/scripts")));
}
示例11: Py_INCREF
static PyObject *meth_QScriptEngineDebugger_attachTo(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QScriptEngine * a0;
QScriptEngineDebugger *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ8", &sipSelf, sipType_QScriptEngineDebugger, &sipCpp, sipType_QScriptEngine, &a0))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->attachTo(a0);
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QScriptEngineDebugger, sipName_attachTo, NULL);
return NULL;
}
示例12: Scene
//.........这里部分代码省略.........
this, SLOT(contextMenuRequested(QPoint)));
// The contextMenuPolicy of infoLabel is now the default one, so that one
// can easily copy-paste its text.
// connect(ui->infoLabel, SIGNAL(customContextMenuRequested(const QPoint & )),
// this, SLOT(showSceneContextMenu(const QPoint &)));
connect(ui->actionRecenterScene, SIGNAL(triggered()),
viewer, SLOT(update()));
connect(ui->actionAntiAliasing, SIGNAL(toggled(bool)),
viewer, SLOT(setAntiAliasing(bool)));
connect(ui->actionDraw_two_sides, SIGNAL(toggled(bool)),
viewer, SLOT(setTwoSides(bool)));
// add the "About CGAL..." and "About demo..." entries
this->addAboutCGAL();
this->addAboutDemo(":/cgal/Polyhedron_3/about.html");
// Connect the button "addButton" with actionLoad
ui->addButton->setDefaultAction(ui->actionLoad);
// Same with "removeButton" and "duplicateButton"
ui->removeButton->setDefaultAction(ui->actionErase);
ui->duplicateButton->setDefaultAction(ui->actionDuplicate);
// Connect actionQuit (Ctrl+Q) and qApp->quit()
connect(ui->actionQuit, SIGNAL(triggered()),
this, SLOT(quit()));
// Connect "Select all items"
connect(ui->actionSelect_all_items, SIGNAL(triggered()),
this, SLOT(selectAll()));
// Recent files menu
this->addRecentFiles(ui->menuFile, ui->actionQuit);
connect(this, SIGNAL(openRecentFile(QString)),
this, SLOT(open(QString)));
// Reset the "Operation menu"
clearMenu(ui->menuOperations);
#ifdef QT_SCRIPT_LIB
std::cerr << "Enable scripts.\n";
script_engine = new QScriptEngine(this);
qScriptRegisterMetaType<Scene_item*>(script_engine,
myScene_itemToScriptValue,
myScene_itemFromScriptValue);
# ifdef QT_SCRIPTTOOLS_LIB
QScriptEngineDebugger* debugger = new QScriptEngineDebugger(this);
debugger->setObjectName("qt script debugger");
QAction* debuggerMenuAction =
menuBar()->addMenu(debugger->createStandardMenu());
debuggerMenuAction->setText(tr("Qt Script &debug"));
for(unsigned int i = 0; i < 9; ++i)
{
QDockWidget* dock = new QDockWidget(debug_widgets_names[i], this);
dock->setObjectName(debug_widgets_names[i]);
dock->setWidget(debugger->widget(debug_widgets[i]));
this->addDockWidget(Qt::BottomDockWidgetArea, dock);
dock->hide();
}
debugger->setAutoShowStandardWindow(false);
debugger->attachTo(script_engine);
# endif // QT_SCRIPTTOOLS_LIB
QScriptValue fun = script_engine->newFunction(myPrintFunction);
script_engine->globalObject().setProperty("print", fun);
// evaluate_script("print('hello', 'world', 'from QtScript!')");
QScriptValue mainWindowObjectValue = script_engine->newQObject(this);
script_engine->globalObject().setProperty("main_window", mainWindowObjectValue);
QScriptValue sceneObjectValue = script_engine->newQObject(scene);
mainWindowObjectValue.setProperty("scene", sceneObjectValue);
script_engine->globalObject().setProperty("scene", sceneObjectValue);
QScriptValue viewerObjectValue = script_engine->newQObject(viewer);
mainWindowObjectValue.setProperty("viewer", viewerObjectValue);
script_engine->globalObject().setProperty("viewer", viewerObjectValue);
QScriptValue cameraObjectValue = script_engine->newQObject(viewer->camera());
viewerObjectValue.setProperty("camera", cameraObjectValue);
script_engine->globalObject().setProperty("camera", cameraObjectValue);
evaluate_script("var plugins = new Array();");
# ifdef QT_SCRIPTTOOLS_LIB
QScriptValue debuggerObjectValue = script_engine->newQObject(debugger);
script_engine->globalObject().setProperty("debugger", debuggerObjectValue);
# endif
#endif
readSettings(); // Among other things, the column widths are stored.
// Load plugins, and re-enable actions that need it.
loadPlugins();
// Setup the submenu of the View menu that can toggle the dockwidgets
Q_FOREACH(QDockWidget* widget, findChildren<QDockWidget*>()) {
ui->menuDockWindows->addAction(widget->toggleViewAction());
}
示例13: if
void setup::setCurrentIndex(XTreeWidgetItem* item)
{
QString uiName = item->data(0, Xt::RawRole).toString();
QString label = "<span style=\" font-size:14pt; font-weight:600;\">%1</span></p></body></html>";
if (_itemMap.contains(uiName) && _itemMap.value(uiName).index >= 0)
{
_stack->setCurrentIndex(_itemMap.value(uiName).index);
_stackLit->setText(label.arg(item->text(0)));
return;
}
else if (_itemMap.contains(uiName) && !item->isDisabled())
{
// First look for a class...
QWidget *w = xtGetScreen(uiName, this);
if (w)
_itemMap[uiName].implementation = w;
else
{
// No class, so look for an extension
XSqlQuery screenq;
screenq.prepare("SELECT * "
" FROM uiform "
" WHERE((uiform_name=:uiform_name)"
" AND (uiform_enabled))"
" ORDER BY uiform_order DESC"
" LIMIT 1;");
screenq.bindValue(":uiform_name", uiName);
screenq.exec();
if (screenq.first())
{
QUiLoader loader;
QByteArray ba = screenq.value("uiform_source").toByteArray();
QBuffer uiFile(&ba);
if (!uiFile.open(QIODevice::ReadOnly))
QMessageBox::critical(0, tr("Could not load UI"),
tr("<p>There was an error loading the UI Form "
"from the database."));
w = loader.load(&uiFile);
w->setObjectName(uiName);
uiFile.close();
// Load scripts if applicable
XSqlQuery scriptq;
scriptq.prepare("SELECT script_source, script_order"
" FROM script"
" WHERE((script_name=:script_name)"
" AND (script_enabled))"
" ORDER BY script_order;");
scriptq.bindValue(":script_name", uiName);
scriptq.exec();
QScriptEngine* engine = new QScriptEngine();
if (_preferences->boolean("EnableScriptDebug"))
{
QScriptEngineDebugger* debugger = new QScriptEngineDebugger(this);
debugger->attachTo(engine);
}
omfgThis->loadScriptGlobals(engine);
QScriptValue mywindow = engine->newQObject(w);
engine->globalObject().setProperty("mywindow", mywindow);
while(scriptq.next())
{
QString script = scriptHandleIncludes(scriptq.value("script_source").toString());
QScriptValue result = engine->evaluate(script, uiName);
if (engine->hasUncaughtException())
{
int line = engine->uncaughtExceptionLineNumber();
qDebug() << "uncaught exception at line" << line << ":" << result.toString();
}
}
_itemMap[uiName].implementation = engine;
}
}
if (w)
{
// Hide buttons out of context here
QWidget* close = w->findChild<QWidget*>("_close");
if (close)
close->hide();
QWidget* buttons = w->findChild<QDialogButtonBox*>();
if (buttons)
buttons->hide();
//Set mode if applicable
int mode = _itemMap.value(uiName).mode;
if (mode && w->inherits("XDialog"))
{
XWidget* x = dynamic_cast<XWidget*>(w);
ParameterList params;
if (mode == cEdit)
params.append("mode", "edit");
else if (mode == cView)
params.append("mode", "view");
if (x)
x->set(params);
}
//.........这里部分代码省略.........