views:

48

answers:

2

Hi,

how can i get the userinput in an input-field?

QObject::connect( webView, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()) );
void slotLoadStarted()
{
   QWebFrame *frame = webView->page()->currentFrame();

   if (frame!=NULL)
   {
      QWebElementCollection collection = frame->findAllElements("input[name=email]");

      foreach (QWebElement element, collection)
      {
        qDebug() << "element.toOuterXml" << element.toOuterXml();
        qDebug() << "element.attribute value:" << element.attribute("value");
      }       
   }

}

if i set the attribute, than it works, but i want to catch the user input, any ideas?

A: 

There seems to be a bug about this issue. I guess one way to go around this issue would be to create an onKeyPress event handler in JavaScript which will update some hidden element with the changed value which you use to read the value from inside the Qt code.

teukkam
A: 

You can use QWebElement::evaluateJavaScript().

qDebug() << "element.attribute value:" << element.evaluateJavaScript("this.value").toString();
Jakub Wieczorek