Closed MGlolenstine closed 4 years ago
That seems to be a gtk+ related question, not a relm question, so you might be able to get better help elsewhere.
Did you put your treeview in a vbox or something so that it can be expanded?
Also, you might not need to call set_model()
and create a new ListStore
on refresh, you might be able to reuse the first model.
I did put my tree_view
into a box, that has orientation
set to Vertical
.
view! {
#[name="window"]
gtk::Window {
gtk::Box {
orientation: Vertical,
hexpand: true,
vexpand: true,
#[name="public_ip"]
gtk::Label{
justify: Justification::Left,
halign: Align::Start,
},
#[name="local_ip"]
gtk::Label{
justify: Justification::Left,
halign: Align::Start,
},
#[name="refresh_button"]
gtk::Button{
label: "Refresh",
clicked => Msg::Refresh,
halign: Align::Start,
},
#[name="tree_view"]
gtk::TreeView{
},
gtk::Button{
clicked => Msg::ApplyPort,
label: "Apply"
},
},
// Use a tuple when you want to both send a message and return a value to
// the GTK+ callback.
delete_event(_, _) => (Msg::Quit, Inhibit(false)),
}
}
Maybe set vexpand: true
on the treeview?
If I set vexpand: true
, the tree_view
doesn't vanish when there's no data
, but it's still not updating.
There might be a problem with the model then. Have you tried the other idea I mentionned in a previous message?
I'm sorry, I was wrong. The vexpand: true
did solve it for me, it's just that I didn't test it correctly.
I didn't try the other idea, but it will be good to look at it when I get to the optimisation.
Thanks for your help.
So I'm inflating
TreeView{}
once and then when theRefresh
button is pressed, I fill a newstore_model
and apply it to thetree_view
. My problem is, that at the start of the program everything works, and when I click theRefresh
button, if the data changed, it changes in thetree_view
, but my problem is if the data is an emptyVec<u16>
, which would mean, that there's no data, it doesn't display it. But that's all working as wanted, but whenever the data is in the array, after the press onRefresh
,tree_view
still shows no data. At first, I thought that the problem was in the button below thetree_view
covering it up when it resets to no elements, but even if I add 500 elements, there still isn't going to be any displayed. I have a counter in thecreate_and_fill_model
for debugging purposes, and yes, it does run as many times, as there are elements, but there's still none displayed.