QWebkit doesn't handle th as a child?



  • Hi,

    I don't have yet setup an easy example for this, but the behavoir I'm seeing currently is, when I traverse a Document with QWebkit, I don't get to see any of the th elements in a table, except the first.
    This is my code:

    @void WebAnalyzer::traverse(const QWebElement &element, size_t index)
    {
    tree_stack.push_back(element);
    if(!element_handler(element.tagName().toLower(),tree_stack,index))
    qDebug() << "no handler for " << element.tagName();

    QWebElement child = element.firstChild();
    size_t nthchild =0;
    while(!child.isNull())
    {
        traverse(child,nthchild);
        qDebug() << element.tagName();
        child = element.nextSibling();
        ++nthchild;
    }
    tree_stack.pop_back();
    

    }@

    I do have a breakpoint in the handler for th,tr etc.
    What I see is, that only the first th element gets visited, not the other, so I'm only having the name of the first instead of all columns in the document...

    Is QWebkit usable for such thing as traversing a HTML Document?

    Any hints?



  • Edited the post now. Handler to th only gets called once, not for all elements. seems strange to me...



  • Solved! There is a little hard to spot bug in this code:

    @ child = element.nextSibling();@

    This needs to be child = child.nextSilbling();
    Unfortunately its also the only way to iterate (begin() end() and iterators would be nice).

    But it works now :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.