Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Dentro e fuori l'if
Forum Updated to NodeBB v4.3 + New Features

Dentro e fuori l'if

Scheduled Pinned Locked Moved Solved Italian
3 Posts 2 Posters 801 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.
  • PollyP Offline
    PollyP Offline
    Polly
    wrote on last edited by
    #1

    Salve ho il seguente codice a cui sto lavorando sempre sui file .xls.

    Questo è il codice

    #include <QCoreApplication>
    #include <QSqlDatabase>
    #include <QSqlQuery>
    #include <QDebug>
    #include <QSqlDriver>
    
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        QString indirizzo("C:\\Users\\Polly-pc\\Desktop\\DaCancellare\\DaXLSaQT\\Roster_Torneo.xls");
        QStringList caratteristiche;
        QSqlDatabase db =  QSqlDatabase::addDatabase("QODBC", "xls_connection");
        db.setDatabaseName("DRIVER={Microsoft Excel Driver (*.xls)}; DBQ=" + indirizzo);
    
        if (db.open())
        {
         QSqlQuery query(db);
         query.exec("select * from [" + QString("Luccini 2010")+"$D4:J5]");
         query.first();
    
        for (int i=0;i<7; i++)
             {
                caratteristiche <<  query.value(i).toString();
             }
    
        qDebug() << caratteristiche.at(0);
         db.close();
    
         QSqlDatabase::removeDatabase("xls_connection");
    
        }
        else
        {
            qDebug() << "It's not possible to open Database";
        }
        qDebug() << caratteristiche.at(0);
     
    
    
        return a.exec();
    }
    

    Vorrei capire per quale motivo le righe

    qDebug() << caratteristiche.at(0);
    

    che ho inserito dentro l'if viene considerata ed eseguita, mentre quella fuori dell'if viene ignorata.

    VRoninV 1 Reply Last reply
    0
    • PollyP Polly

      Salve ho il seguente codice a cui sto lavorando sempre sui file .xls.

      Questo è il codice

      #include <QCoreApplication>
      #include <QSqlDatabase>
      #include <QSqlQuery>
      #include <QDebug>
      #include <QSqlDriver>
      
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          QString indirizzo("C:\\Users\\Polly-pc\\Desktop\\DaCancellare\\DaXLSaQT\\Roster_Torneo.xls");
          QStringList caratteristiche;
          QSqlDatabase db =  QSqlDatabase::addDatabase("QODBC", "xls_connection");
          db.setDatabaseName("DRIVER={Microsoft Excel Driver (*.xls)}; DBQ=" + indirizzo);
      
          if (db.open())
          {
           QSqlQuery query(db);
           query.exec("select * from [" + QString("Luccini 2010")+"$D4:J5]");
           query.first();
      
          for (int i=0;i<7; i++)
               {
                  caratteristiche <<  query.value(i).toString();
               }
      
          qDebug() << caratteristiche.at(0);
           db.close();
      
           QSqlDatabase::removeDatabase("xls_connection");
      
          }
          else
          {
              qDebug() << "It's not possible to open Database";
          }
          qDebug() << caratteristiche.at(0);
       
      
      
          return a.exec();
      }
      

      Vorrei capire per quale motivo le righe

      qDebug() << caratteristiche.at(0);
      

      che ho inserito dentro l'if viene considerata ed eseguita, mentre quella fuori dell'if viene ignorata.

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @Polly said in Dentro e fuori l'if:

      che ho inserito dentro l'if viene considerata ed eseguita, mentre quella fuori dell'if viene ignorata.

      Non viene ignorata. hai provato ad andare passo-passo con un debugger?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      0
      • PollyP Offline
        PollyP Offline
        Polly
        wrote on last edited by
        #3

        Si ho risolto, quando praticamente rimuove il database, automaticamente ignora ogni istruzione.

        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