Struct qt_core::QException

source ·
#[repr(C)]
pub struct QException { /* private fields */ }
Expand description

Qt Concurrent supports throwing and catching exceptions across thread boundaries, provided that the exception inherit from QException and implement two helper functions:

C++ class: QException.

C++ documentation:

Qt Concurrent supports throwing and catching exceptions across thread boundaries, provided that the exception inherit from QException and implement two helper functions:

  class MyException : public QException
  {
  public:
      void raise() const override { throw *this; }
      MyException *clone() const override { return new MyException(*this); }
  };

QException subclasses must be thrown by value and caught by reference:

  try  {
      QtConcurrent::blockingMap(list, throwFunction); // throwFunction throws MyException
  } catch (MyException &e) {
      // handle exception
  }

If you throw an exception that is not a subclass of QException, the Qt functions will throw a QUnhandledException in the receiver thread.

When using QFuture, transferred exceptions will be thrown when calling the following functions:

Implementations§

source§

impl QException

source

pub unsafe fn clone(&self) -> Ptr<QException>

In your QException subclass, reimplement clone() like this:

Calls C++ function: virtual QException* QException::clone() const.

C++ documentation:

In your QException subclass, reimplement clone() like this:


  MyException *MyException::clone() const { return new MyException(*this); }

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QException>> ) -> Ref<QException>

Qt Concurrent supports throwing and catching exceptions across thread boundaries, provided that the exception inherit from QException and implement two helper functions:

Calls C++ function: QException& QException::operator=(const QException& other).

C++ documentation:

Qt Concurrent supports throwing and catching exceptions across thread boundaries, provided that the exception inherit from QException and implement two helper functions:

  class MyException : public QException
  {
  public:
      void raise() const override { throw *this; }
      MyException *clone() const override { return new MyException(*this); }
  };

QException subclasses must be thrown by value and caught by reference:

  try  {
      QtConcurrent::blockingMap(list, throwFunction); // throwFunction throws MyException
  } catch (MyException &e) {
      // handle exception
  }

If you throw an exception that is not a subclass of QException, the Qt functions will throw a QUnhandledException in the receiver thread.

When using QFuture, transferred exceptions will be thrown when calling the following functions:

source

pub unsafe fn new() -> CppBox<QException>

Qt Concurrent supports throwing and catching exceptions across thread boundaries, provided that the exception inherit from QException and implement two helper functions:

Calls C++ function: [constructor] void QException::QException().

C++ documentation:

Qt Concurrent supports throwing and catching exceptions across thread boundaries, provided that the exception inherit from QException and implement two helper functions:

  class MyException : public QException
  {
  public:
      void raise() const override { throw *this; }
      MyException *clone() const override { return new MyException(*this); }
  };

QException subclasses must be thrown by value and caught by reference:

  try  {
      QtConcurrent::blockingMap(list, throwFunction); // throwFunction throws MyException
  } catch (MyException &e) {
      // handle exception
  }

If you throw an exception that is not a subclass of QException, the Qt functions will throw a QUnhandledException in the receiver thread.

When using QFuture, transferred exceptions will be thrown when calling the following functions:

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QException>> ) -> CppBox<QException>

Qt Concurrent supports throwing and catching exceptions across thread boundaries, provided that the exception inherit from QException and implement two helper functions:

Calls C++ function: [constructor] void QException::QException(const QException& other).

C++ documentation:

Qt Concurrent supports throwing and catching exceptions across thread boundaries, provided that the exception inherit from QException and implement two helper functions:

  class MyException : public QException
  {
  public:
      void raise() const override { throw *this; }
      MyException *clone() const override { return new MyException(*this); }
  };

QException subclasses must be thrown by value and caught by reference:

  try  {
      QtConcurrent::blockingMap(list, throwFunction); // throwFunction throws MyException
  } catch (MyException &e) {
      // handle exception
  }

If you throw an exception that is not a subclass of QException, the Qt functions will throw a QUnhandledException in the receiver thread.

When using QFuture, transferred exceptions will be thrown when calling the following functions:

source

pub unsafe fn raise(&self)

In your QException subclass, reimplement raise() like this:

Calls C++ function: virtual void QException::raise() const.

C++ documentation:

In your QException subclass, reimplement raise() like this:


  void MyException::raise() const { throw *this; }

Trait Implementations§

source§

impl CppDeletable for QException

source§

unsafe fn delete(&self)

Destroys the instance of QException. The destructor is virtual.

Calls C++ function: virtual [destructor] void QException::~QException().

C++ documentation:

Destroys the instance of QException. The destructor is virtual.

source§

impl DynamicCast<QUnhandledException> for QException

source§

unsafe fn dynamic_cast(ptr: Ptr<QException>) -> Ptr<QUnhandledException>

Calls C++ function: QUnhandledException* dynamic_cast<QUnhandledException*>(QException* ptr).

source§

impl StaticDowncast<QUnhandledException> for QException

source§

unsafe fn static_downcast(ptr: Ptr<QException>) -> Ptr<QUnhandledException>

Calls C++ function: QUnhandledException* static_cast<QUnhandledException*>(QException* ptr).

source§

impl StaticUpcast<QException> for QUnhandledException

source§

unsafe fn static_upcast(ptr: Ptr<QUnhandledException>) -> Ptr<QException>

Calls C++ function: QException* static_cast<QException*>(QUnhandledException* ptr).

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.