Qt 4.8
Public Types | Signals | Public Functions | List of all members
QScriptEngineDebugger Class Reference

The QScriptEngineDebugger class provides a QScriptEngine debugger. More...

#include <qscriptenginedebugger.h>

Inheritance diagram for QScriptEngineDebugger:
QObject

Public Types

enum  DebuggerAction {
  InterruptAction, ContinueAction, StepIntoAction, StepOverAction,
  StepOutAction, RunToCursorAction, RunToNewScriptAction, ToggleBreakpointAction,
  ClearDebugOutputAction, ClearErrorLogAction, ClearConsoleAction, FindInScriptAction,
  FindNextInScriptAction, FindPreviousInScriptAction, GoToLineAction
}
 This enum specifies the action that the action() function should retrieve. More...
 
enum  DebuggerState { RunningState, SuspendedState }
 This enum specifies the current state of the debugger. More...
 
enum  DebuggerWidget {
  ConsoleWidget, StackWidget, ScriptsWidget, LocalsWidget,
  CodeWidget, CodeFinderWidget, BreakpointsWidget, DebugOutputWidget,
  ErrorLogWidget
}
 This enum decides the widget that the widget() function should retrieve. More...
 

Signals

void evaluationResumed ()
 This signal is emitted when the debugger has resumed script evaluation (e. More...
 
void evaluationSuspended ()
 This signal is emitted when the debugger has suspended script evaluation for whatever reason (e. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

QActionaction (DebuggerAction action) const
 Returns a pointer to the specified action. More...
 
void attachTo (QScriptEngine *engine)
 Attaches to the given engine. More...
 
bool autoShowStandardWindow () const
 Returns whether the standard debugger window is automatically shown when evaluation is suspended. More...
 
QMenucreateStandardMenu (QWidget *parent=0)
 Creates a standard debugger menu with the given parent. More...
 
QToolBarcreateStandardToolBar (QWidget *parent=0)
 Creates a standard debugger toolbar with the given parent. More...
 
void detach ()
 Detaches from the current script engine, if any. More...
 
 QScriptEngineDebugger (QObject *parent=0)
 Constructs a new QScriptEngineDebugger object with the given parent. More...
 
void setAutoShowStandardWindow (bool autoShow)
 Sets whether the standard debugger window is automatically shown when evaluation is suspended. More...
 
QMainWindowstandardWindow () const
 Returns a main window with a standard configuration of the debugger's components. More...
 
DebuggerState state () const
 Returns the current state of the debugger. More...
 
QWidgetwidget (DebuggerWidget widget) const
 Returns a pointer to the instance of the specified standard widget. More...
 
 ~QScriptEngineDebugger ()
 Destroys this QScriptEngineDebugger. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QScriptEngineDebugger class provides a QScriptEngine debugger.

Since
4.5

The QScriptEngineDebugger class provides a debugger that can be embedded into Qt applications that use Qt Script. The debugger enables the application user to inspect the state of the script environment and control script execution.

To attach the debugger to a script engine, call the attachTo() function.

QScriptEngine engine;
debugger.attachTo(&engine);

Once the debugger has been attached to a script engine, you can proceed to evaluate scripts as usual, e.g. by calling QScriptEngine::evaluate(). The debugger will be triggered when an uncaught exception occurs, or when a debugger statement is encountered in a script. It is also possible to interrupt script evaluation at an arbitrary time by triggering the InterruptAction. For instance, to start the debugger when script evaluation starts, you trigger the action before you begin to QScriptEngine::evaluate() the script.

By default, the standard debugger window is shown when evaluation is suspended. This can be changed by calling the setAutoShowStandardWindow() function.

The debugger defines a set of actions that are available, such as stopping execution or printing the contents of a variable. It also provides a set of widgets (components) that display the information available from the debugger and that trigger the actions on request. The actions available are identified by the DebuggerAction enum, and the widgets are identified by the DebuggerWidget enum.

Access to the individual debugger widgets is provided by the widget() function. This makes it possible to arrange the widgets in a custom manner. Similarly, the action() function provides access to the various debugger actions.

The createStandardToolBar() function creates a standard toolbar, and the createStandardMenu() function creates a standard menu; these functions can be useful if you are creating a custom debugger configuration.

The evaluationSuspended() signal is emitted when the debugger has suspended script evaluation and entered interactive mode, i.e., the mode in which it accepts input from the user. The evaluationResumed() signal is emitted when script evaluation is resumed, i.e, when execution control is given back to the script engine. The state() function returns the debugger's current state.

When calling QScriptEngine::evaluate() it is useful to pass a descriptive script name (file name) as second argument, as this is the name that will be displayed by the debugger in the ScriptsWidget; if a name is not passed, the script will be labelled "anonymous".

When evaluation is suspended, the debugger will also suspend the event loop of the script. In the following snippet, the call to QScriptEngine::evaluate() causes the debugger to be triggered, and the function call does not return until the user has finished interacting with the debugger.

engine.evaluate("debugger");

When the Qt Script debugger is running, the C++ application itself is not "frozen". This means that it is possible that more scripts are evaluated, even though the debugger has suspended evaluation of the current script evaluation. For example, a C++ timer might trigger that causes a script function to be called, or the user might click on a button in the main application user interface whose clicked() signal is connected to a script function. This kind of nested evaluation is permitted. The debugger will enter interactive mode for the new script if an exception is thrown or a breakpoint is reached. Note that it will not stop when encountering debugger statements.

Warning
This function is not part of the public interface. The effects are similar to those achieved by typing a program into the debugger's console and evaluating it.

Nested evaluation requires some thought when deciding how the debugger is presented to the user; for example, whether a modal dialog is suitable, or whether some parts of the main application user interface should be disabled while the debugger is running.

Warning
This function is not part of the public interface. Seems unfinished somehow

Debugging inside of a paintEvent() is currently not supported. If you need to debug painting-related script code, that code should be evaluated outside of the C++ paintEvent(), e.g. by rendering to an image, like the Context2D and Tetrix QtScript examples do. This will make the code safe for debugging.

The debugger adds some special properties to the script engine: __FILE__ holds the name of the script in which the current evaluation occurs, and __LINE__ holds the current line number. These are useful when doing print()-style debugging (the messages appear in the debugger's debug output widget).

The Qt Script Debugger Manual describes how to use the debugger. The Context2D Example{Context2D example} shows how to integrate the debugger in applications.

See also
QScriptEngine, {Context2D Example}

Definition at line 63 of file qscriptenginedebugger.h.

Enumerations

◆ DebuggerAction

This enum specifies the action that the action() function should retrieve.

The actions retrieved can be connected to any slot and connected to any widget. Please see the Qt Script Debugger Manual's Console Command Reference for a detailed description of these actions.

  • InterruptAction Suspends script execution as soon as the next script statement is reached.
  • ContinueAction Gives the execution control back to the script engine.
  • StepIntoAction Performs a step action.
  • StepOverAction Performs a next action.
  • StepOutAction Executes the script until the current function returns.
  • RunToCursorAction Continues execution to the selected line (which contains the cursor) in the CodeWidget.
  • RunToNewScriptAction Returns control to the script engine until a new script is executed.
  • ToggleBreakpointAction Toggles a breakpoint at the selected line in the CodeWidget.
  • ClearDebugOutputAction Clears the contents of the DebugOutputWidget.
  • ClearErrorLogAction Clears the contents of the ErrorLogWidget.
  • ClearConsoleAction Clears the contents of the ConsoleWidget.
  • FindInScriptAction Displays the CodeFinderWidget.
  • FindNextInScriptAction Finds next occurrence in the CodeWidget.
  • FindPreviousInScriptAction Finds previous occurrence in the CodeWidget.
  • GoToLineAction Shows the "Go to Line" dialog.
Enumerator
InterruptAction 
ContinueAction 
StepIntoAction 
StepOverAction 
StepOutAction 
RunToCursorAction 
RunToNewScriptAction 
ToggleBreakpointAction 
ClearDebugOutputAction 
ClearErrorLogAction 
ClearConsoleAction 
FindInScriptAction 
FindNextInScriptAction 
FindPreviousInScriptAction 
GoToLineAction 

Definition at line 79 of file qscriptenginedebugger.h.

79  {
95  };

◆ DebuggerState

This enum specifies the current state of the debugger.

Since
4.6
  • RunningState The debugger is running. (Script evaluation is allowed.)
  • SuspendedState The debugger has suspended script evaluation.
Enumerator
RunningState 
SuspendedState 

Definition at line 97 of file qscriptenginedebugger.h.

◆ DebuggerWidget

This enum decides the widget that the widget() function should retrieve.

We treat these widgets in more detail in the Qt Script Debugger Manual.

  • ConsoleWidget Provides a command-line interface to the debugger.
  • StackWidget Shows a backtrace of the script's execution state.
  • ScriptsWidget Displays a list of currently loaded scripts.
  • LocalsWidget Shows the local variables of the current stack frame.
  • CodeWidget Displays the code of the current script.
  • CodeFinderWidget Provides a widget that can search for text in the script shown in the CodeWidget.
  • BreakpointsWidget Shows breakpoints that have been set.
  • DebugOutputWidget Contains output from the print() script function.
  • ErrorLogWidget Shows error messages that have been generated.
Enumerator
ConsoleWidget 
StackWidget 
ScriptsWidget 
LocalsWidget 
CodeWidget 
CodeFinderWidget 
BreakpointsWidget 
DebugOutputWidget 
ErrorLogWidget 

Definition at line 67 of file qscriptenginedebugger.h.

Constructors and Destructors

◆ QScriptEngineDebugger()

QScriptEngineDebugger::QScriptEngineDebugger ( QObject parent = 0)

Constructs a new QScriptEngineDebugger object with the given parent.

To attach a QScriptEngine to the debugger, use attachTo() function.

Definition at line 368 of file qscriptenginedebugger.cpp.

369  : QObject(*new QScriptEngineDebuggerPrivate, parent)
370 {
371 }
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ ~QScriptEngineDebugger()

QScriptEngineDebugger::~QScriptEngineDebugger ( )

Destroys this QScriptEngineDebugger.

Definition at line 376 of file qscriptenginedebugger.cpp.

377 {
378 }

Functions

◆ action()

QAction * QScriptEngineDebugger::action ( DebuggerAction  action) const

Returns a pointer to the specified action.

The actions available are given by the DebuggerAction enum.

With this function, you can add the actions to your own widgets, toolbars, and menus. It is also convenient if you, for example, wish to spice things up with your own groovy icons. The code example below shows how to add actions to a QToolBar.

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);

Note that QScriptEngineDebugger has already added the actions to its standard widgets and standard window.

See also
widget(), createStandardMenu(), createStandardToolBar(), standardWindow()

Definition at line 479 of file qscriptenginedebugger.cpp.

Referenced by standardWindow().

480 {
481  Q_D(const QScriptEngineDebugger);
482  QScriptEngineDebugger *that = const_cast<QScriptEngineDebugger*>(this);
483  that->d_func()->createDebugger();
484  return d->debugger->action(static_cast<QScriptDebugger::DebuggerAction>(static_cast<int>(action)), that);
485 }
double d
Definition: qnumeric_p.h:62
The QScriptEngineDebugger class provides a QScriptEngine debugger.
#define Q_D(Class)
Definition: qglobal.h:2482
QAction * action(DebuggerAction action) const
Returns a pointer to the specified action.

◆ attachTo()

void QScriptEngineDebugger::attachTo ( QScriptEngine engine)

Attaches to the given engine.

The debugger will install a custom agent (using QScriptEngine::setAgent()) to monitor the engine. While the debugger is attached, you should not change the agent; however, if you do have to perform additional monitoring, you must set a proxy agent that forwards all events to the debugger's agent.

See also
detach()

Definition at line 391 of file qscriptenginedebugger.cpp.

392 {
394  if (!engine) {
395  detach();
396  return;
397  }
398  d->createDebugger();
399  if (!d->frontend)
400  d->frontend = new QScriptEngineDebuggerFrontend();
401  d->frontend->attachTo(engine);
402  d->debugger->setFrontend(d->frontend);
403 }
double d
Definition: qnumeric_p.h:62
The QScriptEngineDebugger class provides a QScriptEngine debugger.
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptEngineDebuggerFrontend class provides an in-process debugger frontend. ...
void detach()
Detaches from the current script engine, if any.

◆ autoShowStandardWindow()

bool QScriptEngineDebugger::autoShowStandardWindow ( ) const

Returns whether the standard debugger window is automatically shown when evaluation is suspended.

The default is true.

Definition at line 493 of file qscriptenginedebugger.cpp.

494 {
495  Q_D(const QScriptEngineDebugger);
496  return d->autoShow;
497 }
double d
Definition: qnumeric_p.h:62
The QScriptEngineDebugger class provides a QScriptEngine debugger.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ createStandardMenu()

QMenu * QScriptEngineDebugger::createStandardMenu ( QWidget parent = 0)

Creates a standard debugger menu with the given parent.

Returns the new menu object.

See also
createStandardToolBar()

Definition at line 637 of file qscriptenginedebugger.cpp.

Referenced by standardWindow().

638 {
640  d->createDebugger();
641  return d->debugger->createStandardMenu(parent, this);
642 }
double d
Definition: qnumeric_p.h:62
The QScriptEngineDebugger class provides a QScriptEngine debugger.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ createStandardToolBar()

QToolBar * QScriptEngineDebugger::createStandardToolBar ( QWidget parent = 0)

Creates a standard debugger toolbar with the given parent.

Returns the new toolbar object.

See also
createStandardMenu()

Definition at line 651 of file qscriptenginedebugger.cpp.

Referenced by standardWindow().

652 {
654  d->createDebugger();
655  return d->debugger->createStandardToolBar(parent, this);
656 }
double d
Definition: qnumeric_p.h:62
The QScriptEngineDebugger class provides a QScriptEngine debugger.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ detach()

void QScriptEngineDebugger::detach ( )

Detaches from the current script engine, if any.

See also
attachTo()

Definition at line 410 of file qscriptenginedebugger.cpp.

Referenced by attachTo().

411 {
413  if (d->frontend)
414  d->frontend->detach();
415  if (d->debugger)
416  d->debugger->setFrontend(0);
417 }
double d
Definition: qnumeric_p.h:62
The QScriptEngineDebugger class provides a QScriptEngine debugger.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ evaluationResumed

QScriptEngineDebugger::evaluationResumed ( )
signal

This signal is emitted when the debugger has resumed script evaluation (e.

g. the user gave the "continue" command).

\sa evaluationSuspended()

◆ evaluationSuspended

QScriptEngineDebugger::evaluationSuspended ( )
signal

This signal is emitted when the debugger has suspended script evaluation for whatever reason (e.

g. due to an uncaught script exception, or due to a breakpoint being triggered).

See also
evaluationResumed()

Referenced by setAutoShowStandardWindow().

◆ setAutoShowStandardWindow()

void QScriptEngineDebugger::setAutoShowStandardWindow ( bool  autoShow)

Sets whether the standard debugger window is automatically shown when evaluation is suspended.

If autoShow is true, the window will be automatically shown, otherwise it will not.

Definition at line 504 of file qscriptenginedebugger.cpp.

505 {
507  if (autoShow == d->autoShow)
508  return;
509  if (autoShow) {
511  this, SLOT(_q_showStandardWindow()));
512  } else {
514  this, SLOT(_q_showStandardWindow()));
515  }
516  d->autoShow = autoShow;
517 }
double d
Definition: qnumeric_p.h:62
#define SLOT(a)
Definition: qobjectdefs.h:226
The QScriptEngineDebugger class provides a QScriptEngine debugger.
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
void evaluationSuspended()
This signal is emitted when the debugger has suspended script evaluation for whatever reason (e...

◆ standardWindow()

QMainWindow * QScriptEngineDebugger::standardWindow ( ) const

Returns a main window with a standard configuration of the debugger's components.

See also
createStandardMenu(), createStandardToolBar()

Definition at line 526 of file qscriptenginedebugger.cpp.

527 {
528  Q_D(const QScriptEngineDebugger);
529  if (d->standardWindow)
530  return d->standardWindow;
531  if (!QApplication::instance())
532  return 0;
533  QScriptEngineDebugger *that = const_cast<QScriptEngineDebugger*>(this);
534 
535  QMainWindow *win = new QMainWindow();
536  QDockWidget *scriptsDock = new QDockWidget(win);
537  scriptsDock->setObjectName(QLatin1String("qtscriptdebugger_scriptsDockWidget"));
538  scriptsDock->setWindowTitle(tr("Loaded Scripts"));
539  scriptsDock->setWidget(widget(ScriptsWidget));
540  win->addDockWidget(Qt::LeftDockWidgetArea, scriptsDock);
541 
542  QDockWidget *breakpointsDock = new QDockWidget(win);
543  breakpointsDock->setObjectName(QLatin1String("qtscriptdebugger_breakpointsDockWidget"));
544  breakpointsDock->setWindowTitle(tr("Breakpoints"));
545  breakpointsDock->setWidget(widget(BreakpointsWidget));
546  win->addDockWidget(Qt::LeftDockWidgetArea, breakpointsDock);
547 
548  QDockWidget *stackDock = new QDockWidget(win);
549  stackDock->setObjectName(QLatin1String("qtscriptdebugger_stackDockWidget"));
550  stackDock->setWindowTitle(tr("Stack"));
551  stackDock->setWidget(widget(StackWidget));
552  win->addDockWidget(Qt::RightDockWidgetArea, stackDock);
553 
554  QDockWidget *localsDock = new QDockWidget(win);
555  localsDock->setObjectName(QLatin1String("qtscriptdebugger_localsDockWidget"));
556  localsDock->setWindowTitle(tr("Locals"));
557  localsDock->setWidget(widget(LocalsWidget));
558  win->addDockWidget(Qt::RightDockWidgetArea, localsDock);
559 
560  QDockWidget *consoleDock = new QDockWidget(win);
561  consoleDock->setObjectName(QLatin1String("qtscriptdebugger_consoleDockWidget"));
562  consoleDock->setWindowTitle(tr("Console"));
563  consoleDock->setWidget(widget(ConsoleWidget));
564  win->addDockWidget(Qt::BottomDockWidgetArea, consoleDock);
565 
566  QDockWidget *debugOutputDock = new QDockWidget(win);
567  debugOutputDock->setObjectName(QLatin1String("qtscriptdebugger_debugOutputDockWidget"));
568  debugOutputDock->setWindowTitle(tr("Debug Output"));
569  debugOutputDock->setWidget(widget(DebugOutputWidget));
570  win->addDockWidget(Qt::BottomDockWidgetArea, debugOutputDock);
571 
572  QDockWidget *errorLogDock = new QDockWidget(win);
573  errorLogDock->setObjectName(QLatin1String("qtscriptdebugger_errorLogDockWidget"));
574  errorLogDock->setWindowTitle(tr("Error Log"));
575  errorLogDock->setWidget(widget(ErrorLogWidget));
576  win->addDockWidget(Qt::BottomDockWidgetArea, errorLogDock);
577 
578  win->tabifyDockWidget(errorLogDock, debugOutputDock);
579  win->tabifyDockWidget(debugOutputDock, consoleDock);
580 
582 
583 #ifndef QT_NO_MENUBAR
584  win->menuBar()->addMenu(that->createStandardMenu(win));
585 
586  QMenu *editMenu = win->menuBar()->addMenu(tr("Search"));
587  editMenu->addAction(action(FindInScriptAction));
590  editMenu->addSeparator();
591  editMenu->addAction(action(GoToLineAction));
592 
593  QMenu *viewMenu = win->menuBar()->addMenu(tr("View"));
594  viewMenu->addAction(scriptsDock->toggleViewAction());
595  viewMenu->addAction(breakpointsDock->toggleViewAction());
596  viewMenu->addAction(stackDock->toggleViewAction());
597  viewMenu->addAction(localsDock->toggleViewAction());
598  viewMenu->addAction(consoleDock->toggleViewAction());
599  viewMenu->addAction(debugOutputDock->toggleViewAction());
600  viewMenu->addAction(errorLogDock->toggleViewAction());
601 #endif
602 
603  QWidget *central = new QWidget();
604  QVBoxLayout *vbox = new QVBoxLayout(central);
605  vbox->setMargin(0);
606  vbox->addWidget(widget(CodeWidget));
609  win->setCentralWidget(central);
610 
611  win->setWindowTitle(tr("Qt Script Debugger"));
613 
614  QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
615  QVariant geometry = settings.value(QLatin1String("Qt/scripttools/debugging/mainWindowGeometry"));
616  if (geometry.isValid())
617  win->restoreGeometry(geometry.toByteArray());
618  QVariant state = settings.value(QLatin1String("Qt/scripttools/debugging/mainWindowState"));
619  if (state.isValid())
620  win->restoreState(state.toByteArray());
621 
622  WidgetClosedNotifier *closedNotifier = new WidgetClosedNotifier(win, that);
623  QObject::connect(closedNotifier, SIGNAL(widgetClosed()),
624  action(ContinueAction), SLOT(trigger()));
625 
626  const_cast<QScriptEngineDebuggerPrivate*>(d)->standardWindow = win;
627  return win;
628 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
QToolBar * createStandardToolBar(QWidget *parent=0)
Creates a standard debugger toolbar with the given parent.
void setCentralWidget(QWidget *widget)
Sets the given widget to be the main window&#39;s central widget.
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
QWidget * widget(DebuggerWidget widget) const
Returns a pointer to the instance of the specified standard widget.
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
QAction * toggleViewAction() const
Returns a checkable action that can be used to show or close this dock widget.
#define SLOT(a)
Definition: qobjectdefs.h:226
The QScriptEngineDebugger class provides a QScriptEngine debugger.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QAction * addAction(const QString &text)
This convenience function creates a new action with text.
Definition: qmenu.cpp:1453
#define Q_D(Class)
Definition: qglobal.h:2482
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void setWindowTitle(const QString &)
Definition: qwidget.cpp:6312
bool restoreState(const QByteArray &state, int version=0)
Restores the state of this mainwindow&#39;s toolbars and dockwidgets.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void tabifyDockWidget(QDockWidget *first, QDockWidget *second)
Moves second dock widget on top of first dock widget, creating a tabbed docked area in the main windo...
QAction * addSeparator()
This convenience function creates a new separator action, i.e.
Definition: qmenu.cpp:1583
void setWidget(QWidget *widget)
Sets the widget for the dock widget to widget.
void hide()
Hides the widget.
Definition: qwidget.h:501
QMenuBar * menuBar() const
Returns the menu bar for the main window.
QAction * addMenu(QMenu *menu)
Appends menu to the menu bar.
Definition: qmenubar.cpp:937
void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget)
Adds the given dockwidget to the specified area.
void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar)
Adds the toolbar into the specified area in this main window.
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
QAction * action(DebuggerAction action) const
Returns a pointer to the specified action.
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
QMainWindow * standardWindow() const
Returns a main window with a standard configuration of the debugger&#39;s components. ...
friend class QWidget
Definition: qobject.h:329
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:149
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
void setUnifiedTitleAndToolBarOnMac(bool set)
QMenu * createStandardMenu(QWidget *parent=0)
Creates a standard debugger menu with the given parent.
void setMargin(int)
Definition: qlayout.cpp:464
bool restoreGeometry(const QByteArray &geometry)
Restores the geometry and state top-level widgets stored in the byte array geometry.
Definition: qwidget.cpp:7313
DebuggerState state() const
Returns the current state of the debugger.

◆ state()

QScriptEngineDebugger::DebuggerState QScriptEngineDebugger::state ( ) const

Returns the current state of the debugger.

Since
4.6
See also
evaluationResumed()
evaluationSuspended()

Definition at line 430 of file qscriptenginedebugger.cpp.

Referenced by standardWindow().

431 {
432  Q_D(const QScriptEngineDebugger);
433  return !d->debugger || !d->debugger->isInteractive() ? SuspendedState : RunningState;
434 }
double d
Definition: qnumeric_p.h:62
The QScriptEngineDebugger class provides a QScriptEngine debugger.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ widget()

QWidget * QScriptEngineDebugger::widget ( DebuggerWidget  widget) const

Returns a pointer to the instance of the specified standard widget.

The widgets available are defined by the DebuggerWidget enum.

A main window containing all widgets is returned by standardWindow(). If you do not want to use this window, you can fetch the individual widgets with this function. For instance, the code example below shows how to set up a layout containing a code window and a stack widget.

QWidget *codeWindow = debugger->widget(QScriptEngineDebugger::CodeWidget);
QWidget *stackWidget = debugger->widget(QScriptEngineDebugger::StackWidget);
layout->addWidget(codeWindow);
layout->addWidget(stackWidget);

Note that you need to set setAutoShowStandardWindow() to false; if not, the standard window will be shown regardless.

See also
action(), standardWindow(), setAutoShowStandardWindow()

Definition at line 456 of file qscriptenginedebugger.cpp.

Referenced by standardWindow().

457 {
458  Q_D(const QScriptEngineDebugger);
459  const_cast<QScriptEngineDebuggerPrivate*>(d)->createDebugger();
460  return d->debugger->widget(static_cast<QScriptDebugger::DebuggerWidget>(static_cast<int>(widget)));
461 }
double d
Definition: qnumeric_p.h:62
QWidget * widget(DebuggerWidget widget) const
Returns a pointer to the instance of the specified standard widget.
The QScriptEngineDebugger class provides a QScriptEngine debugger.
#define Q_D(Class)
Definition: qglobal.h:2482

The documentation for this class was generated from the following files: