Show a message when a search returns no results

Hi,

I’m currently building a application using Gtk4 and Libadwaita and I have a searchable table in it. I’ve implemented the table using a columnview that displays a filtered list model, whose filter is updated according to the entry of a search bar.

Currently, when no element of the columnview matches the search bar entry, the columnview appears empty, but I would like to show some feedback to the user indicating that their search was unsuccessful.

I’ve seen that I can use a Libadwaita status page to achieve this, but I’m unsure how to implement it. I guess I should do something like creating the widget and then only displaying it when the search fails, but I don’t know how this could be done.

Best

You can use a stack with two pages: one with the columnview, and the other with a label saying “no results found”, and then switch between the two pages depending on the number of results.

1 Like