Important: Please read the Qt Code of Conduct -

Tree View with varying column counts

  • I would like to show in a QTreeView a model that has two levels of items. The child and parent items would have a different qty of columns and different column names. The parent items will all have 4 columns. Each parent item would have several child items with 5 columns that have no relation to the parent's columns.

    Below is a quick sketch of roughly how I would want it to appear. The parent columns show information about shipments between warehouses, the child items represent actual lines of inventory that make up that shipment. In this example "Shipment #3" and Shipment #5" are expanded to show child items.

    -Can this be achieved with a QTreeView?
    -Could I use a standard model, or do I need to create my own?
    -Do you know of any other similar examples on how I might implement this, or have any suggestions?