Hi everybody,
tody I use QWebView to load a html page, and want to add a custom HTML attribute "qlevel", someone told me QtWebKit doesn't offer DOM for HTML, so i want to use javascript to add this attribute, after adding the attribute, I want to export the HTML source, here is my code below:

Qt Code:
  1. //---------add custom attribute "qlevel"
  2. QString strScript = "test.setAttribute = ('qlevel', '123');";
  3. QWebFrame* pFrame = m_pView->page()->mainFrame();
  4. pFrame->evaluateJavaScript(strScript);
  5.  
  6. //----------export the new html source
  7. strScript="alert(test.innerText.toString());";
  8. QMessageBox::information(this, tr("Test"), pFrame->evaluateJavaScript(strScript).toString());
  9.  
  10. QString strText = m_pView->page()->mainFrame()->toHtml();
  11. QFile file("c:\\test.html");
  12.  
  13. file.open(QFile::WriteOnly);
  14. QTextStream ts(&file);
  15.  
  16. ts << strText;
  17. file.close();
To copy to clipboard, switch view to plain text mode 


the "test" in javascript is an id of TD tag, now in the new HTML source code, I couldn't see the ‘qlevel’ atrribute, why? Thanks!