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. Writing data of type QVector<QVector<QString>> into a text file
Forum Updated to NodeBB v4.3 + New Features

Writing data of type QVector<QVector<QString>> into a text file

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 330 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.
  • ashajgA Offline
    ashajgA Offline
    ashajg
    wrote on last edited by
    #1

    Hi Guys,

    I want to write some data into text file.
    My data type is

    QVector<QVector<QString>>table;
    

    but I am getting an error

    no match for 'operator<<' (operand types are 'QTextStream' and 'QVector<QVector<QString> >')
    
             out << table;
             ~~~~^~~~~~~~~~~~~~
    

    How can I write this data to a file?

    KroMignonK 1 Reply Last reply
    0
    • ashajgA ashajg

      Hi Guys,

      I want to write some data into text file.
      My data type is

      QVector<QVector<QString>>table;
      

      but I am getting an error

      no match for 'operator<<' (operand types are 'QTextStream' and 'QVector<QVector<QString> >')
      
               out << table;
               ~~~~^~~~~~~~~~~~~~
      

      How can I write this data to a file?

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #2

      @ashajg The easiest way is to iterate through the lists:

      for(const auto &v : table)
      {
          for(const auto &str : v)
             out << str; 
      }
      
      

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      aha_1980A 1 Reply Last reply
      7
      • KroMignonK KroMignon

        @ashajg The easiest way is to iterate through the lists:

        for(const auto &v : table)
        {
            for(const auto &str : v)
               out << str; 
        }
        
        
        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        I just have to add to @KroMignon, if table is not const, you should use qAsConst:

        for(const auto &v : qAsConst(table))
        {
            for(const auto &str : v)
               out << str; 
        }
        

        Qt has to stay free or it will die.

        1 Reply Last reply
        6
        • ashajgA Offline
          ashajgA Offline
          ashajg
          wrote on last edited by
          #4

          @KroMignon @aha_1980
          Its working..
          Thanks for help!!!

          1 Reply Last reply
          2

          • Login

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