Bool Qlist check if every item in list is true



  • hi
    i have a list of bool

    QList<bool> check;
    

    how can i check all items is true?



  • I'd go with std::all_of.



  • @ARASHz4 usually by iterating over your list and checking.

    luckilyfor you, QList has a predefined function that will do exactly what you want it to, without doing anyting yourself.

    bool QList::contains(const T &value) const

    QList<bool> check;
    bool alltrue = !check.contains(false);
    


  • std::all_of(check.constBegin(),check.constEnd(),[](bool val){return val;});


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.