Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Esportare/Salvare QML TableView in TXT file e viceversa

Esportare/Salvare QML TableView in TXT file e viceversa

Scheduled Pinned Locked Moved Unsolved Italian
2 Posts 1 Posters 543 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    sluci
    wrote on last edited by
    #1

    Il mio problema è come trattare/vedere la TableView in QML come se fosse una QTableView tipo ui->TableView.rowCount(); ecc... per reperite il numero row e column della cella per gestirla.
    Ho visto esempi con QSqlQuery ma non sono riuscito a collegare la TableView (TABLE)

    Grazie per l'aiuto

           QSqlQuery query;
           query.prepare("SELECT COUNT(*) FROM " + TABLE + " ;");
           query.exec();
           query.first();
           return query.value(0).toInt();
    
    void FilesRW::exportTXT()
    {   
          QFile txtFile ( "F:/fileExample.txt" );
               if ( txtFile.open ( QIODevice :: WriteOnly ))
          {
              QTextStream textStream ( &txtFile );
              QStringList stringList ; 
    
              for (int row = 0 ; row < this->rowCount(); row++)
              {
                  stringList.clear (); 
    
                  for ( int column = 0 ; column < 5 ; column ++ )  {                
                     stringList << this->data(this->index(row, column), Qt::UserRole + 1 + column ). toString ();             
                  }
      textStream << stringList.join ( ';' ) + "\n" ;
              }          
              txtFile . close ();
          }
    }
    1 Reply Last reply
    0
    • S Offline
      S Offline
      sluci
      wrote on last edited by
      #2
      This post is deleted!
      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