Nominate our 2022 Qt Champions!

QScriptEngine issue

  • I have a a number of labels (named, label1, label2, .... label27).

    I tried to use QScriptEngine to evaluate a command save in a QString variable, Instead of repeating the same line for over 27 times. I am using the code shown below.

    QScriptEngine engine;
    QString filename = QString("EDataBase.label%1->setPixmap(QPixmap::fromImage(qimage,0))").arg(Label);

    where EDataBase is the name of the mainwindow, Label is a count for all labels.

    The code compiles and runs correctly, but it does not show the image saved in qimage.

    Is there something wrong with the code? am I doing it right?

    Note that I checked qimage have the correct data.

    Thanks for your help in advance.

    [EDIT: code formatting, please wrap in @-tags, Volker]

Log in to reply