'Finding element in QList

Suppose I have a struct SignalError which has an element "errName" and many other elements:

typedef struct SignalError
{
    QString errName;
    .....
};

I create QList of this struct:

QList<SignalError> signalErrList;

I will append the struct element to the QList using append call.

SignalError sgErr1 = {"Error_1"};

signalerrList.append(sgErr1);

Before appending the element to the list I want to check if there is any element with the same name "errName" already existing in the QList or not. If it is then I will not add the element to the list. How do I do this?

Also, should I create a list of objects like:

QList<SignalError> signalErrList;

or create list of pointer to the object:

QList<SignalError*> signalErrList;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source