Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_corelib_thread_qexception.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5
6class MyException : public QException
7{
8public:
9 void raise() const override { throw *this; }
10 MyException *clone() const override { return new MyException(*this); }
11};
12
14
15
17
18try {
19 QtConcurrent::blockingMap(list, throwFunction); // throwFunction throws MyException
20} catch (MyException &e) {
21 // handle exception
22}
23
25
26
28
29void MyException::raise() const { throw *this; }
30
32
33
35
36MyException *MyException::clone() const { return new MyException(*this); }
37
39
41
42try {
43 auto f = QtConcurrent::run([] { throw MyException {}; });
44 // ...
45} catch (const QUnhandledException &e) {
46 try {
47 if (e.exception())
48 std::rethrow_exception(e.exception());
49 } catch (const MyException &ex) {
50 // Process 'ex'
51 }
52}
53
void raise() const override
[1]
MyException * clone() const override
[2]
\inmodule QtCore
Definition qexception.h:22
\inmodule QtCore
Definition qexception.h:31
std::exception_ptr exception() const
QTCONCURRENT_RUN_NODISCARD auto run(QThreadPool *pool, Function &&f, Args &&...args)
void blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor map)
Calls function once for each item in sequence.
GLfloat GLfloat f
QList< int > list
[14]