Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › Add icon to ListElement dynamically

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17624

    Felgo User

    Is it possible to add an icon to ListElement dynamically?

    Setting them in a static way works fine:

    model: [
              { name: "Airplane Mode", icon: IconType.plane }
            ]

     

    Dynamic approach:

    ... 
      model: mainModel
    ...
    
    ListModel {
    	id: mainModel
    }
    function add()
    {
    	var obj= {};
    	obj.name = " MyName"; 
    	obj.icon = IconType.plus;
    
    	var arr = [];
    	arr.push(obj);
    	
    	mainModel.append(arr);
    }
    

     

    #17800

    Günther
    Felgo Team

    Hi!

    Yes, you can use ListModel.append to add items dynamically.

    If your list view does not show the change automatically, you can also call list.modelChanged() to manually signal a change in your model.
    The view then updates accordingly.

    Best,

    Günther

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded