Skip to content

Adding Buttons dynamically #5362

Answered by Vadoola
peter1960 asked this question in Q&A
Jun 6, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

What @ogoffart suggested is exactly what I'm doing in my program and it works well. My application is themeable and the theme selection buttons are determined at runtime based on the theme files found on disk.

If you want to look at my code for a more detailed example feel free: https://github.com/Vadoola/Tomotroid

Relevant Sections:

  • fn load_themes() in settings.rs
  • The following code from main.rs
    let settings = settings::load_settings();
    let theme_model: Rc<VecModel<JsonTheme>> = Rc::new(VecModel::from(themes));
    window.global::<ThemeCallbacks>().set_themes(ModelRc::from(theme_model.clone()));
  • The themeconfig.slint file
  • The section of main.rs with the .on_theme_changed() callback (search …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Vadoola
Comment options

Answer selected by peter1960
@peter1960
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants