Mantid
Loading...
Searching...
No Matches
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
MantidQt::API::MantidDialog Class Reference

#include <MantidDialog.h>

Inheritance diagram for MantidQt::API::MantidDialog:
FindReplaceDialog MantidQt::API::ScriptRepositoryView MantidQt::MantidWidgets::DiagResults MantidQt::MantidWidgets::EditLocalParameterDialog MantidQt::MantidWidgets::SaveWorkspaces MantidQt::MantidWidgets::SelectFunctionDialog MantidQt::MantidWidgets::SequentialFitDialog FindDialog

Signals

void runAsPythonScript (const QString &code, bool)
 

Public Member Functions

 MantidDialog (QWidget *parent=nullptr, const Qt::WindowFlags &flags=Qt::WindowCloseButtonHint|Qt::WindowType::WindowTitleHint)
 DefaultConstructor. More...
 
 ~MantidDialog () override
 Destructor. More...
 

Static Public Member Functions

static bool handle (QObject *receiver, const std::exception &e)
 Handles the exception caught in an event handler. More...
 

Protected Member Functions

virtual void handleException (const std::exception &e)
 Override this method to handle an exception in a derived class. More...
 
QString runPythonCode (const QString &code, bool no_output=false)
 Run python code that is passed to it and, optionally, return anything it wrote to standard output as a string. More...
 

Private Attributes

PythonRunner m_pyRunner
 This object implements the runPythonCode() function, by emitting the code as a runAsPythonScript signal. More...
 

Detailed Description

Dialog derived from this class can capture and handle exceptions raised in
its event handlers. To be able to do this override QAplication::notify

method:

 bool MyApplication::notify( QObject * receiver, QEvent * event )
 {
     bool res = false;
     try
     {
         res = QApplication::notify(receiver,event);
     }
     catch(std::exception& e)
     {
         if (MantidQt::API::MantidDialog::handle(receiver,e))
             return true; // stops event propagation
         else

do somethig else ... }

return res; }

@author Roman Tolchenov, Tessella plc
@date 24/04/2009

Definition at line 54 of file MantidDialog.h.

Constructor & Destructor Documentation

◆ MantidDialog()

MantidDialog::MantidDialog ( QWidget *  parent = nullptr,
const Qt::WindowFlags &  flags = Qt::WindowCloseButtonHint | Qt::WindowType::WindowTitleHint 
)

DefaultConstructor.

Default Constructor.

Definition at line 22 of file MantidDialog.cpp.

References m_pyRunner, and runAsPythonScript().

◆ ~MantidDialog()

MantidDialog::~MantidDialog ( )
overridedefault

Destructor.

Member Function Documentation

◆ handle()

bool MantidDialog::handle ( QObject *  receiver,
const std::exception &  e 
)
static

Handles the exception caught in an event handler.

Checks if receiver derives from MantidDialog.

If it does calls the virtual handleException method.

Parameters
receiver:: The Qt event receiver
e:: The exception
Returns
True if the exception was handled, false otherwise.

Definition at line 41 of file MantidDialog.cpp.

References obj.

◆ handleException()

void MantidDialog::handleException ( const std::exception &  e)
protectedvirtual

Override this method to handle an exception in a derived class.

Parameters
e:: exception to handle

Definition at line 56 of file MantidDialog.cpp.

◆ runAsPythonScript

void MantidQt::API::MantidDialog::runAsPythonScript ( const QString &  code,
bool   
)
signal

Referenced by MantidDialog().

◆ runPythonCode()

QString MantidDialog::runPythonCode ( const QString &  code,
bool  no_output = false 
)
protected

Run python code that is passed to it and, optionally, return anything it wrote to standard output as a string.

Run a piece of python code and return any output that it writes to stdout.

Parameters
code:: the Python commands to execute
no_output:: if set to true this method returns an empty string, if false it returns the output from any Python print statements
Returns
output from Python print statements unless no_output is false

Definition at line 68 of file MantidDialog.cpp.

References m_pyRunner, and MantidQt::API::PythonRunner::runPythonCode().

Referenced by MantidQt::MantidWidgets::SaveWorkspaces::saveSel().

Member Data Documentation

◆ m_pyRunner

PythonRunner MantidQt::API::MantidDialog::m_pyRunner
private

This object implements the runPythonCode() function, by emitting the code as a runAsPythonScript signal.

Definition at line 82 of file MantidDialog.h.

Referenced by MantidDialog(), and runPythonCode().


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