QT Widget ListView with Custom Designed Items

  • Hi there,

    Hi can i use Widget based List Control with custom layouted/designed items?
    Which control should i use, how ill set my custom designed widget to be used as template for list items to appear?

    alt text


  • Lifetime Qt Champion


    Normally you would use a delegate to draw it as you want it to look
    (this is kinda a trick as it only draws as widgets until you edit the row, then its
    live widgets. but it has good performance.)

    Alternatively for only a FEW items, one can use
    (and a ListWidget )
    Here we simply put a live widget on top of the row item.
    This has bad performance with many items and on small boards/phones.

    Alternatively for a few items, you can use
    a QScrollArea.

    In most cases you will be most happy with a model and a view and a delegate as you can share the model with more views and its fast.

  • @mrjj Thank you for your reply, i tried to understand stardelegate example but its bit overwhelming for me as a new user.
    So my question is Cant we use visual custom widget as a delegate instead of overriding Paint method and design it with pure code?

  • Lifetime Qt Champion

    The setItemWidget can be used to inset a widget ( with subwidgets ) on a item but
    its not possible to use as a delegate as such.
    This method is very easy but also a bit heavy with many items.
    But on a desktop class pc. many items is maybe a thousands.
    So if app is not to run on smartphone/ Pi boards then it works pretty ok.
    However, the delegate and painting is best in terms of memory use and performance.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.