Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using non standard types in listview struct/model? #5048

Closed
Gibbz opened this issue Apr 12, 2024 · 3 comments
Closed

Using non standard types in listview struct/model? #5048

Gibbz opened this issue Apr 12, 2024 · 3 comments
Labels
a:language-slint Compiler for the .slint language (mO,bF)

Comments

@Gibbz
Copy link

Gibbz commented Apr 12, 2024

In my appwindow.slint file I have a list view that I want to populate from my rust code. I'm doing a bluetooth scanner, so want to keep a list of peripheral devices in the listview item.

How do I go about setting that up in the slint file?
What I have

@rust-attr(derive(serde::Serialize, serde::Deserialize))
export struct ScanItem  {
    title: string,
    checked: bool,
    peripheral: btleplug::api::Peripheral, // <-- this doent work
}
@ogoffart
Copy link
Member

Slint struct and other types can currently only contains fields of type known to Slint.
I don't know if we can support this usecase.
It can be worked around by using an integer id, and have mapping between id and the actual type in Rust.

@hunger hunger added the a:language-slint Compiler for the .slint language (mO,bF) label May 2, 2024
@Areopagitics
Copy link

Areopagitics commented May 18, 2024

Slint struct and other types can currently only contains fields of type known to Slint. I don't know if we can support this usecase. It can be worked around by using an integer id, and have mapping between id and the actual type in Rust.

True, it's possible to do this with an id; but if you want to do anything more complicated inside the for loop, like calling a common function that affects each child individually, I think you would need the ability to pass more complicated types of variables as parameters in the function, like Widget types. This would be a huge bonus. This is one huge advantage of Flutter. It is similar to issue #4891.

It would be interesting to know how difficult this would be. I think this is a bottle-neck for a lot of functionality.

@ogoffart
Copy link
Member

ogoffart commented Jun 4, 2024

We would need to support importing rust struct.
I think this would be a duplicate of #1726
So it would allow to import Rust struct from Slint code
Closing this issue as duplicate of #1726

@ogoffart ogoffart closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:language-slint Compiler for the .slint language (mO,bF)
Projects
None yet
Development

No branches or pull requests

4 participants