cancel
Showing results for 
Search instead for 
Did you mean: 

how to size customList in view using model const

JPabl.1
Senior

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

1 ACCEPTED SOLUTION

Accepted Solutions
LouisB
ST Employee

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,

Louis BOUDO
ST Software Developer | TouchGFX

View solution in original post

2 REPLIES 2
Andrew Neil
Evangelist III

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

 

AndrewNeil_0-1729181324952.png

 

Moved to the TouchGFX forum

LouisB
ST Employee

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,

Louis BOUDO
ST Software Developer | TouchGFX