QML ListView Header and Footer Items?

10,069

You should assign header/footer items to some external reference as below:

Window {
  property Item listHeaderItem: null
  Component {
    id: listHeaderComponent
    Item {
      id: headerItem
      width: listView.width; height: 0
      Component.onCompleted: rootWindow.listHeaderItem = headerItem
    }
  }
  ListView {
    header: listHeaderComponent
  }}
Share:
10,069
Prismatic
Author by

Prismatic

People would say I'm: quiet, ambivalent Favourite language: c++ Least favourite language: c++ Current stuff I'm doing or have done recently: basic 3d (opengl, scenegraphs, etc), gis (map visualization mostly), vehicle diagnostics (obd) Stuff I would like the opportunity to work with: robotics in medicine or transportation

Updated on June 04, 2022

Comments

  • Prismatic
    Prismatic almost 2 years

    I'd like to access the header and footer items in a QML ListView in a manner similar to calling currentItem to get the current delegate instance, but I can't figure out how. I'd appreciate any advice.