Qt
6.x
The Qt SDK
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
6
class
MyException
:
public
QException
7
{
8
public
:
9
void
raise
()
const override
{
throw
*
this
; }
10
MyException
*
clone
()
const override
{
return
new
MyException
(*
this
); }
11
};
12
14
15
17
18
try
{
19
QtConcurrent::blockingMap
(
list
, throwFunction);
// throwFunction throws MyException
20
}
catch
(
MyException
&
e
) {
21
// handle exception
22
}
23
25
26
28
29
void
MyException::raise
()
const
{
throw
*
this
; }
30
32
33
35
36
MyException
*
MyException::clone
()
const
{
return
new
MyException
(*
this
); }
37
39
41
42
try
{
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
MyException
[0]
Definition
src_corelib_thread_qexception.cpp:7
MyException::raise
void raise() const override
[1]
Definition
src_corelib_thread_qexception.cpp:9
MyException::clone
MyException * clone() const override
[2]
Definition
src_corelib_thread_qexception.cpp:10
QException
\inmodule QtCore
Definition
qexception.h:22
QUnhandledException
\inmodule QtCore
Definition
qexception.h:31
e
double e
Definition
doc_src_qalgorithms.cpp:6
QtConcurrent::blockingMap
void blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor map)
Calls function once for each item in sequence.
Definition
qtconcurrentmap.h:395
QtConcurrent::run
auto run(QThreadPool *pool, Function &&f, Args &&...args)
Definition
qtconcurrentrun.h:40
f
GLfloat GLfloat f
Definition
qopengles2ext.h:795
list
QList< int > list
[14]
Definition
src_concurrent_qtconcurrentfilter.cpp:140
qtbase
src
corelib
doc
snippets
code
src_corelib_thread_qexception.cpp
Generated by
1.9.7