summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/scriptdebugger.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:34:13 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:34:13 (GMT)
commit67ad0519fd165acee4a4d2a94fa502e9e4847bd0 (patch)
tree1dbf50b3dff8d5ca7e9344733968c72704eb15ff /doc/src/snippets/scriptdebugger.cpp
downloadQt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2
Long live Qt!
Diffstat (limited to 'doc/src/snippets/scriptdebugger.cpp')
-rw-r--r--doc/src/snippets/scriptdebugger.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/doc/src/snippets/scriptdebugger.cpp b/doc/src/snippets/scriptdebugger.cpp
new file mode 100644
index 0000000..a1889d5
--- /dev/null
+++ b/doc/src/snippets/scriptdebugger.cpp
@@ -0,0 +1,64 @@
+
+#include <QtGui>
+#include <QtScript>
+#include <QtScriptTools>
+
+// 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();
+}
+