Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
src_corelib_plugin_qlibrary.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
4
#
include
<
QLibrary
>
5
6
int
examples
(QLibrary *library)
7
{
8
{
9
//! [0]
10
QLibrary myLib(
"mylib"
);
11
typedef
void
(*MyPrototype)();
12
MyPrototype myFunction = (MyPrototype) myLib.resolve(
"mysymbol"
);
13
if
(myFunction)
14
myFunction();
15
//! [0]
16
}
17
18
{
19
//! [1]
20
typedef
void
(*MyPrototype)();
21
MyPrototype myFunction =
22
(MyPrototype) QLibrary::resolve(
"mylib"
,
"mysymbol"
);
23
if
(myFunction)
24
myFunction();
25
//! [1]
26
}
27
28
{
29
//! [2]
30
typedef
int
(*AvgFunction)(
int
,
int
);
31
32
AvgFunction avg = (AvgFunction) library->resolve(
"avg"
);
33
if
(avg)
34
return
avg(5, 8);
35
else
36
return
-1;
37
//! [2]
38
}
39
}
40
41
//! [4]
42
#
ifdef
Q_OS_WIN
43
#
define
MY_EXPORT
__declspec
(
dllexport
)
44
#
else
45
#
define
MY_EXPORT
46
#
endif
47
//! [4]
48
49
//! [3]
50
extern
"C"
MY_EXPORT
int
avg
(
int
a,
int
b)
51
{
52
return
(a + b) / 2;
53
}
54
//! [3]
examples
int examples(QLibrary *library)
Definition
src_corelib_plugin_qlibrary.cpp:6
MY_EXPORT
#define MY_EXPORT
[4]
Definition
src_corelib_plugin_qlibrary.cpp:45
avg
MY_EXPORT int avg(int a, int b)
[4]
Definition
src_corelib_plugin_qlibrary.cpp:50
qtbase
src
corelib
doc
snippets
code
src_corelib_plugin_qlibrary.cpp
Generated on
for Qt by
1.18.0