1 year ago

#372036

test-img

Lidbey

C++ QT convert list to one of overloaded functions

I am looking for a way to convert a list of QVariants into one of overloaded functions that takes either 1, 2, 3 or 4 QVariants.

My initial idea is to just make a switch statement on the list's length and call functions based on it, but I am not sure if it is the only solution for this problem, and it doesn't look very scalable:

switch(list.length())
{
case 0:
 fun();
case 1:
 fun(list[0]);
 break;
case 2:
 fun(list[0], list[1]);
 break;
case 3:
 fun(list[0], list[1], list[2]);
 break;
...
}

c++

list

qt

overloading

0 Answers

Your Answer

Accepted video resources