Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Customising ComboBox (delegateModel)

Customising ComboBox (delegateModel)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bob64
    wrote on last edited by
    #1

    I implemented a customised combo box some time ago when I knew very little about QML (I don't know very much now!). I based it on following Qt examples and and other information I found online and didn't necessarily get all of the details.

    Looking at it again recently, something initially confused me. The Popup is customised via a ListView content item but the delegate for the list view is defined as the delegate property of the ComboBox. Given that the content item of the Popup is somewhat arbitrary, how does it know to use the delegate from the containing Popup?

    The answer appears to be in the Qt example code which I based mine on:

              contentItem: ListView {
                  clip: true
                  implicitHeight: contentHeight
                  model: control.popup.visible ? control.delegateModel : null
                  ...
    

    Presumably delegateModel here is an instance of a DelegateModel that is constructed by the ComboBox implementation.

    Is my understanding correct? I thought it worth asking this question as it does seem to be somewhat glossed over by the Qt documentation (is the delegateModel property explained anywhere?) and perhaps it might help someone else in future who is searching for an explanation.

    1 Reply Last reply
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      Yes this is correct. DelegateModel is a special beast containing both the model and the delegates created from it.

      When you assign it to the model of a view you don't have to assign a delegate to the view.

      B 1 Reply Last reply
      1
      • GrecKoG GrecKo

        Yes this is correct. DelegateModel is a special beast containing both the model and the delegates created from it.

        When you assign it to the model of a view you don't have to assign a delegate to the view.

        B Offline
        B Offline
        Bob64
        wrote on last edited by
        #3

        @GrecKo Thanks for confirming.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved