Globals in c++ (no global<T> function?) #12159
-
|
I wanted to follow the advice in https://docs.slint.dev/latest/docs/slint/guide/language/coding/globals and use a global like Are the docs wrong here or is it missing in the public API? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
The // in your main .slint file:
export { Logic } from "logic.slint";Then Please don't use the Working C++ example in the repo: https://github.com/slint-ui/slint/blob/master/demos/printerdemo/cpp/main.cpp |
Beta Was this translation helpful? Give feedback.
The
global<T>()accessor is generated, but only for globals that are exported (or re-exported) from the main fileThen
app->global<Logic>()will be available in the generated header.Please don't use the
globalsmember you found, it's an internal implementation detail of the generated code, not part of the public API. It can change or be renamed at any time without notice. Always go throughglobal<T>().Working C++ example in the repo: https://github.com/slint-ui/slint/blob/master/demos/printerdemo/cpp/main.cpp
printer_demo->global<PrinterQueue>()