Skip to content

Commit 4e8c0ff

Browse files
Montelahayzen-kdab
authored andcommitted
Add Display for QPolygon/QPolygonF
1 parent dfb5675 commit 4e8c0ff

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

crates/cxx-qt-lib/src/gui/qpolygon.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ mod ffi {
1919
type QPoint = crate::QPoint;
2020
include!("cxx-qt-lib/qrect.h");
2121
type QRect = crate::QRect;
22+
include!("cxx-qt-lib/qstring.h");
23+
type QString = crate::QString;
2224

2325
include!("cxx-qt-lib/qpolygon.h");
2426
type QPolygon = super::QPolygon;
@@ -81,6 +83,10 @@ mod ffi {
8183
#[doc(hidden)]
8284
#[rust_name = "qpolygon_eq"]
8385
fn operatorEq(a: &QPolygon, b: &QPolygon) -> bool;
86+
87+
#[doc(hidden)]
88+
#[rust_name = "qpolygon_to_qstring"]
89+
fn toQString(value: &QPolygon) -> QString;
8490
}
8591
}
8692

@@ -131,6 +137,12 @@ impl PartialEq for QPolygon {
131137
}
132138
}
133139

140+
impl std::fmt::Display for QPolygon {
141+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
142+
write!(f, "{}", ffi::qpolygon_to_qstring(self))
143+
}
144+
}
145+
134146
impl Eq for QPolygon {}
135147

136148
// Safety:

crates/cxx-qt-lib/src/gui/qpolygonf.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ mod ffi {
2020
type QRectF = crate::QRectF;
2121
include!("cxx-qt-lib/qpolygon.h");
2222
type QPolygon = crate::QPolygon;
23+
include!("cxx-qt-lib/qstring.h");
24+
type QString = crate::QString;
2325

2426
include!("cxx-qt-lib/qpolygonf.h");
2527
type QPolygonF = super::QPolygonF;
@@ -79,6 +81,10 @@ mod ffi {
7981
#[doc(hidden)]
8082
#[rust_name = "qpolygonf_eq"]
8183
fn operatorEq(a: &QPolygonF, b: &QPolygonF) -> bool;
84+
85+
#[doc(hidden)]
86+
#[rust_name = "qpolygonf_to_qstring"]
87+
fn toQString(value: &QPolygonF) -> QString;
8288
}
8389
}
8490

@@ -120,6 +126,12 @@ impl PartialEq for QPolygonF {
120126
}
121127
}
122128

129+
impl std::fmt::Display for QPolygonF {
130+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
131+
write!(f, "{}", ffi::qpolygonf_to_qstring(self))
132+
}
133+
}
134+
123135
impl Eq for QPolygonF {}
124136

125137
// Safety:

0 commit comments

Comments
 (0)