mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Add a qt_viewer example that uses QWidget
This commit is contained in:
parent
90d3953d42
commit
1dba04721a
12 changed files with 249 additions and 1 deletions
|
@ -15,6 +15,12 @@ LICENSE END */
|
|||
|
||||
#include <optional>
|
||||
|
||||
#define SIXTYFPS_QT_INTEGRATION // In the future, should be defined by cmake only if this is enabled
|
||||
#ifdef SIXTYFPS_QT_INTEGRATION
|
||||
class QWidget;
|
||||
#endif
|
||||
|
||||
|
||||
namespace sixtyfps::cbindgen_private {
|
||||
// This has to stay opaque, but VRc don't compile if it is just forward declared
|
||||
struct ErasedComponentBox : vtable::Dyn
|
||||
|
@ -501,6 +507,17 @@ public:
|
|||
cbindgen_private::sixtyfps_run_event_loop();
|
||||
hide();
|
||||
}
|
||||
#ifdef SIXTYFPS_QT_INTEGRATION
|
||||
/// Return a QWidget for this instance.
|
||||
/// This function is only available if the qt graphical backend was compiled in, and
|
||||
/// it may return nullptr if the Qt backend is not used at runtime.
|
||||
QWidget *qwidget() const {
|
||||
cbindgen_private::ComponentWindowOpaque win;
|
||||
cbindgen_private::sixtyfps_interpreter_component_instance_window(inner(), &win);
|
||||
return reinterpret_cast<QWidget *>(cbindgen_private::sixtyfps_qt_get_widget(
|
||||
reinterpret_cast<cbindgen_private::ComponentWindow *>(&win)));
|
||||
}
|
||||
#endif
|
||||
|
||||
bool set_property(std::string_view name, const Value &value) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue