aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp')
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp b/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp
new file mode 100644
index 000000000..06590610c
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_corelib_plugin_qlibrary.cpp
@@ -0,0 +1,44 @@
+//! [0]
+QLibrary myLib("mylib");
+typedef void (*MyPrototype)();
+MyPrototype myFunction = (MyPrototype) myLib.resolve("mysymbol");
+if (myFunction)
+ myFunction();
+//! [0]
+
+
+//! [1]
+typedef void (*MyPrototype)();
+MyPrototype myFunction =
+ (MyPrototype) QLibrary::resolve("mylib", "mysymbol");
+if (myFunction)
+ myFunction();
+//! [1]
+
+
+//! [2]
+typedef int (*AvgFunction)(int, int);
+
+AvgFunction avg = (AvgFunction) library->resolve("avg");
+if (avg)
+ return avg(5, 8);
+else
+ return -1;
+//! [2]
+
+
+//! [3]
+extern "C" MY_EXPORT int avg(int a, int b)
+{
+ return (a + b) / 2;
+}
+//! [3]
+
+
+//! [4]
+#ifdef Q_WS_WIN
+#define MY_EXPORT __declspec(dllexport)
+#else
+#define MY_EXPORT
+#endif
+//! [4]