Change javascript variable from Qt



  • hello everyone,
    I am new to QT .I want to know that how can I change javascript variable from Qt.

    suppose in JAVASCRIPT.js one variable is var name="sagar";
    now I want to change that javascript variable called name with new name "john" .

    So please let me know how to do that.



  • There is no context for answer to your question.
    Please, give us more details about the context, where and when you want to change the variable... otherwise the only answer can be:
    "just do it" :-)

    @name = "john";@



  • In javascript.js file contains :
    var ItemName="coldrinks";
    var ItemValue="100";
    function myfunction()
    {
    document.getElementById('nItemValue')[removed]=ItemValue;
    document.getElementById('nItemName')[removed]=ItemName;
    }

    In my Qt program;

    QString nItemName ="potato chips";
    QString nItemPrice = 20;

    QUrl iUrl=Url::fromLocalFile((QDir::current().absoluteFilePath("./html_pages/alert_item_recognized.html")));
    ui->webView->settings()->clearMemoryCaches();
    ui->webView->load(iUrl);
    ui->webView->show();

    I want to just know any method for edit javascript file before alert_item_recognized.html opened. I want to edit contents of javascript.js..

    before html page loads javascript file should edit with
    var ItemName="potato chips";
    var ItemValue="20";


Log in to reply
 

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