So I have the following HTML and am trying to change which item is selected.

HTML Code:
  1. <select name="coolselectbox">
  2. <option value="default" selected="selected">---</option>
  3. <option value="something">Something</option>
  4. <option value="something-else">Something Else</option>
  5. </select>
To copy to clipboard, switch view to plain text mode 

Here's what I've tried:

Cpp Code:
  1. QWebElement defaultOpt =
  2. this->page()->mainFrame()->findFirstElement("option[value=default]");
  3.  
  4. QWebelement somethingOpt =
  5. this->page()->mainFrame()->findFirstElement("option[value=something]");
  6.  
  7. defaultOpt.removeAttribute("selected");
  8. somethingOpt.setAttribute("selected", "selected");
To copy to clipboard, switch view to plain text mode 

And then also:

Cpp Code:
  1. QWebElement selectBox =
  2. this->page()->mainFrame()->findFirstElement("select[name=coolselectbox]");
  3.  
  4. selectBox.setAttribute("value", "something-else");
To copy to clipboard, switch view to plain text mode 


However neither of these seems to get the job done, at least visually, however I may have overlooked something.

Does anyone know a Qt solution, or is there perhaps some JavaScript snippet I can run to do this? Also what about a similar approach for radio buttons, which are essentially the same thing?