little precision on the for loop



  • watch the code please ....

    it displays a QString in a Qlabel

    suppose we created a label calling eg "text" that will contain what must affcher on the window that is displayed when the program and also a QString QList that will contain a display in the label like this:

    QList <QString> list;
    << list "one" << "two" << "three";
    the loop below displays the text in the table from a for loop as you can see ...

    for (int i (0), list.size (), ++ i)

    {

    Texte.setText (list [i])

    }

    my question is how to skip the display of a table value ... I want to show by example "one" and "three" but not "two" which command should i use please? ??



  • i found !!!
    i should use the keyword "continue"



  • Here's an example for skipping the "two":

    for (int i (0), list.size (), ++ i)
    {
        if(list [i] != "two")
        {
            Texte.setText (list [i]);
        }
    }
    

    You could also use the keyword "continue" to skip an iteration :

    for (int i (0), list.size (), ++ i)
    {
        if(...)
        {
            continue;
        }
        Texte.setText (list [i]);
    }
    

Log in to reply
 

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