Skip to main content
JPabl.1
Associate III
October 17, 2024
Solved

how to size customList in view using model const

  • October 17, 2024
  • 2 replies
  • 668 views

Hi there Touchgfx team!

 

I have a view with a custom container list as in the ListLayout example. 

 

 

class test_selectionView : public test_selectionViewBase
{
public:
 test_selectionView();
 virtual ~test_selectionView() {}
 virtual void setupScreen();
 virtual void tearDownScreen();

 /**
 * Handler of list element clicks.
 */
 void listElementClicked(CustomListElement &element);

protected:
 static const int number_of_select_test_kit_list_elements = 30;
 CustomListElement select_test_kit_list_elements[number_of_select_test_kit_list_elements];


 // Callback that is assigned to each list element
 Callback<test_selectionView, CustomListElement &> listElementClickedCallback;
};

 

 

 

I would like to have the number of elements in the model, and access it with a get method. Right now, you can see I'm harcoding the "30" value in the view. 

I already created number_of_select_test_kit_list_elements in the model and created the get method, because that number will be used across several screens. 

How can I create the CustomListElement using the get method from the model? 

 

Thanks a lot in advance

Best answer by LouisB

Hi @JPabl.1,

You can refer to this tutorial to create a model : https://support.touchgfx.com/academy/tutorials/tutorial-03.
To have the number of element you have to create your own "count" function the model.

BR,

2 replies

Andrew Neil
Super User
October 17, 2024

You posted this in the 'Feedback' forum - that's not the right place for it!

 

AndrewNeil_0-1729181324952.png

 

Moved to the TouchGFX forum

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
LouisBBest answer
ST Employee
October 18, 2024

Hi @JPabl.1,

You can refer to this tutorial to create a model : https://support.touchgfx.com/academy/tutorials/tutorial-03.
To have the number of element you have to create your own "count" function the model.

BR,