Skip Navigation

What is the correct way to place a Kirigami.SearchField inside the window header?

Hello! I'm trying to do this:

but I can't seem to find a "good" way to do it:

if I just place it in the Kirigami.Page it is displayed, well, in the page, as in the image above.

Kirigami.ApplicationWindow {
   pageStack.initialPage: Kirigami.ScrollablePage {
      Kirigami.SearchField { // TODO move in the page header
         id: searchField
         Layout.fillWidth: true
      }
   }
}

if I place it in the header of the window it is displayed before the actual header even:

Kirigami.ApplicationWindow {
    header: Kirigami.SearchField { // TODO move in the page header
         id: searchField
         Layout.fillWidth: true
      }
   pageStack.initialPage: Kirigami.ScrollablePage {
     
   }
}

if I place it just before the Page it goes inside the header, but all aligned to the top instead of nicely in the center:

Kirigami.ApplicationWindow {
    Kirigami.SearchField { // TODO move in the page header
         id: searchField
         Layout.fillWidth: true
      }
   pageStack.initialPage: Kirigami.ScrollablePage {
     
   }
}

what is the correct way of doing this?

thanks in advance!

4

You're viewing a single thread.

4 comments
  • So what you want to do is put a Kirigami.SearchField inside the global toolbar created by the Kirigami.Page. It's not a header.

    In the first case you're putting it inside the page, and because it's a direct child of a Kirigami.Page, it is automatically laid out for you, which is fine, but not what you want.

    In the second case you're putting it in the header of the ApplicationWindow, but you actually want to put in the global toolbar of the page, so it's not what you want.

    In the third case you're just putting a SearchField before the initialPage, so it's loaded on the same level as the page, it's not what you want.

    You can put it in the header property of the Kirigami.Page, but the header area of the page doesn't include the global toolbar, so they just happen to be close together by chance.

    The way I'd have expected to do that would be to override the globalToolBarItem of the Kirigami.Page, but it's read only, so I don't really know how to help you with that. You should ask in the Kirigami Matrix room or in the Discuss forum.