Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting data via XQuery then sorting and using it
QtWS25 Last Chance

Getting data via XQuery then sorting and using it

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 424 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicky j
    wrote on last edited by
    #1

    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");
    xqueryFile.open(QIODevice::ReadWrite);

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

    }
    @

    thanks!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved