I am someone who is new to QT. I am creating a HTML report page in QT. In that I am creating a table and populating my data into it using the following:
htmlFile.open(path);
htmlFile<<"<!DOCTYPE html><html><head></head><body>";
htmlFile<<"<table id='myTable'>"
"<tr>"
"<td>Feature</td>"
"<td>Test Count</td>"
"<td>PASS</td>"
"<td>FAIL</td>"
"<td>SKIPPED</td>"
"</tr>";
I have a script that displays the row index, column and the value of the cell.This is my script :
QString val;
htmlFile<<"<script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>"
"<script>"
"$(document).ready(function(){"
"$('#myTable td').click(function() {"
"var column_num = parseInt( $(this).index() ) + 1;"
"var row_num = parseInt( $(this).parent().index() )+1;"
"var txt='Row:' +row_num+' Column : '+column_num;"
"txt+=' Value: '+ document.getElementById('myTable').rows[row_num-1].cells[column_num-1].innerHTML; "
"alert(txt); }); });"
"</script>";
Now I want the variable 'txt' to be used in my class, ie, something like val=txt (which definitely is not possible directly). Is there any way to do so? Can a global variable help me?
This is my first HTML and script attempt. So I ma bit confused. Thanks in advance!
You can use an xml parser so your html file can be load has object. qt provide an xml parser see http://doc.qt.io/qt-4.8/qdomdocument.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.