@@ -15,7 +15,56 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO
15
15
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16
16
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
17
*/
18
- //! Various bindings and wrappers for Qt classes, enums, member/static methods and functions.
18
+ //! This crate contains manually generated bindings to Qt basic value types.
19
+ //! It is meant to be used by other crates, such as the `qmetaobject` crate which re-expose them
20
+ //!
21
+ //! The Qt types are basically exposed using the [`cpp`] crate. They have manually writen rust idiomatic
22
+ //! API which expose the C++ API.
23
+ //! These types are the direct equivalent of the Qt types and are exposed on the stack.
24
+ //!
25
+ //! In addition, the build script of this crate expose some metadata that are usefull to build.
26
+ //! Build scripts of crates that depends directly from this crate will have the following
27
+ //! environment variable when the build script is run:
28
+ //! - `DEP_QT_VERSION`: The Qt version as given by qmake
29
+ //! - `DEP_QT_INCLUDE_PATH`: The include directory to give to the `cpp_build` crate to locate the Qt headers
30
+ //! - `DEP_QT_LIBRARY_PATH`: The path containing the Qt libraries.
31
+ //!
32
+ //! ## Usage with the `cpp` crate
33
+ //!
34
+ //! Here is an example that make use of the types exposed by this crate in combinaition with the `cpp` crate
35
+ //! to call native API:
36
+ //!
37
+ //! In `Cargo.toml`
38
+ //! ```toml
39
+ //! #...
40
+ //! [dependencies]
41
+ //! qttype = "0.1"
42
+ //! cpp = "0.5"
43
+ //! #...
44
+ //! [build-dependencies]
45
+ //! cpp_build = "0.5.4"
46
+ //! ```
47
+ //!
48
+ //! Then in the `build.rs` file:
49
+ //! ```ignore
50
+ //! fn main() {
51
+ //! cpp_build::Config::new()
52
+ //! .include(&qt_include_path)
53
+ //! .include(format!("{}/QtGui", qt_include_path))
54
+ //! .include(format!("{}/QtCore", qt_include_path))
55
+ //! .build("src/main.rs");
56
+ //! }
57
+ //! ```
58
+ //!
59
+ //! With that, you can now use the types inside your .rs files
60
+ //!
61
+ //! ```ignore
62
+ //! let byte_array = qttypes::QByteArray::from("Hello World!");
63
+ //! cpp::cpp!([byte_array as "QByteArray"] { qDebug() << byte_array; });
64
+ //! ```
65
+ //!
66
+ //! You will find a small but working example in the
67
+ //! [qmetaobject reporisoty](https://github.com/woboq/qmetaobject-rs/tree/master/examples/graph)
19
68
20
69
use cpp:: { cpp, cpp_class} ;
21
70
use std:: convert:: From ;
0 commit comments