slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.93k stars 567 forks source link

how to remove the behind black cmd window? what is setting? #2678

Closed mylovetop closed 1 year ago

mylovetop commented 1 year ago

cargo build --release

generate todo.exe

while click the todo.exe, as the below image

image

the code:

main.rs

slint::include_modules!();
fn main() {
    HelloWorld::new().unwrap().run().unwrap();
}

build.rs

fn main() {
    slint_build::compile("ui/hello.slint").unwrap();
}

ui/hello.slint

import { VerticalBox, Button } from "std-widgets.slint";
export component HelloWorld inherits Window {
    in-out property <int> counter: 0;
    VerticalBox {
        button := Button {
            text: "Button, pressed " + root.counter + " times";
            clicked => {
                root.counter += 1;
            }
        }
    }
}

cargo.toml

[package]
name = "todo"
build = "build.rs"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
slint = "1.0.2"

[build-dependencies]
slint-build = "1.0.2"

[profile.dev.build-override]
debug=true
[profile.release.build-override]
debug=true

thank you!

ogoffart commented 1 year ago

I think you need #![windows_subsystem = "windows"] We should document that better.

mylovetop commented 1 year ago

it is work.

thank you

mylovetop commented 1 year ago

thank you