Search code examples
javascriptc++qtwt

How to Make a Slider Witty like javascript?


I have started a project that Web pages serving from C++ application.

there is a lot of javascript tutorial from beginners to to novice. and how can i embed this javascript slider to web page made by Witty C++? i Have one server made by Qt run on Windows, one windows client made by Qt and one android client made by Qt, now i am started to web client with Witty and Qt.

But i need to only witty and Javascript Tutorial make slider.

Javascript Tutorial

But this link only show pop up message.

there is no basic or any example for slider. Can any anybody show how it is made?

thanks


Solution

  • ok my error is setTimeout function in javascript. there is no fail with witty, this slider is great me , now going on styling wow:)

    WImage* img = new WImage(root());
    
    img->setId("imgslider");
    std::string command = std::string(      "var i = 1;" 
                                              "var path = new Array();" 
                                              "path[0] = \"1.jpg\";" 
                                              "path[1] = \"2.jpg\";" 
                                              "path[2] = \"3.jpg\";" 
    "var ifr = document.getElementById('imgslider');"
    "function start(counter){" 
                                              "if(counter < 10){" 
                                                "setTimeout(function(){" 
                                                  "counter++;" 
                                                  "counter = counter % 3;" 
                                                  "ifr.src = path[counter];" 
                                                  "console.log(counter);" 
                                                  "console.log(path[counter]);" 
                                                  "console.log(ifr.src);" 
                                                  "start(counter);" 
                                                "}, 1000);" 
                                              "}" 
                                            "}" 
                                            "start(1);" 
                                            );
    img->doJavaScript(command);