Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

contain in QStringList


  • Banned

    Hej fellas,

    I am struggeling while coding and i thought maybe you can help me! ;)

    I have a QStringList which contains name, email and birthdate. And that like 10-15 times. The list gets this inofrmation from a CSV-adressbook and that all works fine.
    Now i wanna find out if a specific String is contained in the QStringList?

    I check the current Date with QDate and wanna see if the currentdate matches the Birthdate. If it mateches it should get the row:

    void datecheck::gettodayskid(QStringList list) 
    {
    
        QString item;
    
        for(int i=0; i<list.length();i++){
            item = list[i];
        if(item.contains(date)){
            
            qDebug()<<item;
    
               }
         }
    }
    
    code_text
    
    
    I hope someone maybe can help me!
    Cya,
    Markus

  • Lifetime Qt Champion

    Hi,

    I think you are looking for QStringList::contains or rather QStringList::indexOf.


  • Banned

    Thanks a lot it seems to work! Thanks alot


Log in to reply