Skip to content

Commit 3d1592d

Browse files
committed
Some documentation
1 parent 074f343 commit 3d1592d

File tree

2 files changed

+53
-4
lines changed

2 files changed

+53
-4
lines changed

examples/graph/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ extern crate cpp_build;
2020
fn main() {
2121
let qt_include_path = std::env::var("DEP_QT_INCLUDE_PATH").unwrap();
2222
cpp_build::Config::new()
23-
.include(qt_include_path.trim())
24-
.include(qt_include_path.trim().to_owned() + "/QtQuick")
25-
.include(qt_include_path.trim().to_owned() + "/QtCore")
23+
.include(&qt_include_path)
24+
.include(format!("{}/QtQuick", qt_include_path))
25+
.include(format!("{}/QtCore", qt_include_path))
2626
.build("src/main.rs");
2727
}

qttypes/src/lib.rs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,56 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO
1515
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1616
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1717
*/
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)
1968
2069
use cpp::{cpp, cpp_class};
2170
use std::convert::From;

0 commit comments

Comments
 (0)