Qt World Summit: Submit your Presentation

Getting data via XQuery then sorting and using it

  • Hello there,

    I would like my program to gather results via an XQuery file and use the results as parameters for a function.
    I am using a slightly modified version of the XQuery example to sift through the XML results. As you can see, the switch() function will contain the code to be executed when the condition is met. In this case (pun not intended) I would like it to store the value of the result. That value will later be used as a parameter for another function. So how can I store the values of the results and access them at the end of this function? Heres my code so far:

    @void sideBar::initializeSideBar()
    QFile xqueryFile("/Users/nick/Desktop/files for NovaBrowser/sidebarQuery.xq");

    QXmlQuery query;
    query.setQuery(&xqueryFile, QUrl::fromLocalFile(xqueryFile.fileName()));
    QXmlResultItems result;
    QXmlItem item(result.next());
    while (!item.isNull()) {
             if (item.isAtomicValue()) {
                 QVariant v = item.toAtomicValue();
                 switch (v.type()) {
                     case QVariant::Int:
                     case QVariant::String:
                         // error
             else if (item.isNode()) {
                 QXmlNodeModelIndex i = item.toNodeModelIndex();
             item = result.next();



Log in to reply