Loop for ui object



  • I have to add a for loop Condition for this

    @ui->l1_mono->addItem(item1,0);
    ui->l1_mono->addItem(item2,1);
    ui->l1_mono->addItem(item3,2);
    ui->l2_mono->addItem(item1,0);
    ui->l2_mono->addItem(item2,1);
    ui->l2_mono->addItem(item3,2);
    ui->l3_mono->addItem(item1,0);
    ui->l3_mono->addItem(item2,1);
    ui->l3_mono->addItem(item3,2);
    ui->l4_mono->addItem(item1,0);
    ui->l4_mono->addItem(item2,1);
    ui->l4_mono->addItem(item3,2);
    ui->l5_mono->addItem(item1,0);
    ui->l5_mono->addItem(item2,1);
    ui->l5_mono->addItem(item3,2);
    ui->l6_mono->addItem(item1,0);
    ui->l6_mono->addItem(item2,1);
    ui->l6_mono->addItem(item3,2);
    ui->l7_mono->addItem(item1,0);
    ui->l7_mono->addItem(item2,1);
    ui->l7_mono->addItem(item3,2);
    ui->l8_mono->addItem(item1,0);
    ui->l8_mono->addItem(item2,1);
    ui->l8_mono->addItem(item3,2);@

    I need a help Please.....



  • The same to us to understand your problem. Please give some info about what you are trying to do.



  • What I understood... Try to store the lX_mono and the itemY in arrays or similar and iterate over them. (X:=0..5, Y:=0..2) You understand? ;-)



  • @
    for (int i = 1; i <= 8; i++)
    {
    QListWidget widget = findChild<QListWidget>(QString("l%1_mono").arg(i));
    if (widget != 0)
    {
    widget->addItem(item2, 0);
    widget->addItem(item3, 1);
    widget->addItem(item1, 2);
    }
    }
    @
    Brain to terminal.


Log in to reply
 

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