Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QT cross compilation error for raspberry pi - QStringList and QFile members missing
Forum Updated to NodeBB v4.3 + New Features

QT cross compilation error for raspberry pi - QStringList and QFile members missing

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 552 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.
  • R Offline
    R Offline
    RiyG22
    wrote on 19 Oct 2020, 09:55 last edited by
    #1

    Hi,
    I am working with QT for cross compiling the application for raspberry pi.
    I want to create a CSV file and save the data for further analysis.

    Below is the sample code :

    #include <QList>
    #include <QColor>
    #include <QString>
    #include <QStringList>
    #include <QFile>
    #include <QTextStream>
    #include <QDebug>
    
    QList<QRgb> GetPixels()
    {
        QList<QRgb> pixels;
        pixels << qRgb(11, 255, 0) << qRgb(167, 209, 89) << qRgb(34, 55, 12);
    
        return pixels;
    }
    
    QList<QStringList> PixelsToStrings(const QList<QRgb>& pixels)
    {
        QList<QStringList> strings;
        for (int i = 0; i < pixels.size(); ++i)
        {
            QStringList values;
            values << QString::number(qRed(pixels.at(i))) <<
                      QString::number(qGreen(pixels.at(i))) <<
                      QString::number(qBlue(pixels.at(i)));
    
            strings << values;
        }
    
        return strings;
    
    }
    
    void WriteToCSV(const QList<QStringList>& pixels)
    {
        // Open csv-file
        QFile file("pixels.csv");
        file.open(QIODevice::Append | QIODevice::Text);
    
        // Write data to file
        QTextStream stream(&file);
        QString separator(",");
        for (int i = 0; i < pixels.size(); ++i)
        {
            stream << pixels.at(i).join(separator) << endl;
        }
    
        stream.flush();
        file.close();
    }
    
    QList<QStringList> ReadCSV()
    {
        // Open csv-file
        QFile file("pixels.csv");
        file.open(QIODevice::ReadOnly | QIODevice::Text);
    
        // Read data from file
        QTextStream stream(&file);
        QList<QStringList> data;
        QString separator(",");
        while (stream.atEnd() == false)
        {
            QString line = stream.readLine();
            data << line.split(separator);
        }
    
        file.close();
        return data;
    }
    
    void Print(const QList<QStringList>& data)
    {
        for (int i = 0; i < data.size(); ++i)
        {
            qDebug() << data.at(i).join(", ");
        }
    }
    
    int main()
    {
        QList<QRgb> pixels = GetPixels();
        QList<QStringList> pixelsStr = PixelsToStrings(pixels);
        WriteToCSV(pixelsStr);
    
        QList<QStringList> readData = ReadCSV();
        Print(readData);
    
        return 0;
    }
    

    This code is working fine on native compiler - Linux (ubuntu) but when cross compiling for raspberry pi, Errors facing -

    1. .Join member is missing in QStringList , there are other members like isEmpty etc also missing.
    2. .open - No matching member function for call to 'open'.

    If anyone faced similar issues and knows the solution, please share with me. It would be really appreciated.

    Similar post I found - https://forum.qt.io/topic/118482/qstringlist-missing-methods

    K 1 Reply Last reply 19 Oct 2020, 10:03
    0
    • R RiyG22
      19 Oct 2020, 09:55

      Hi,
      I am working with QT for cross compiling the application for raspberry pi.
      I want to create a CSV file and save the data for further analysis.

      Below is the sample code :

      #include <QList>
      #include <QColor>
      #include <QString>
      #include <QStringList>
      #include <QFile>
      #include <QTextStream>
      #include <QDebug>
      
      QList<QRgb> GetPixels()
      {
          QList<QRgb> pixels;
          pixels << qRgb(11, 255, 0) << qRgb(167, 209, 89) << qRgb(34, 55, 12);
      
          return pixels;
      }
      
      QList<QStringList> PixelsToStrings(const QList<QRgb>& pixels)
      {
          QList<QStringList> strings;
          for (int i = 0; i < pixels.size(); ++i)
          {
              QStringList values;
              values << QString::number(qRed(pixels.at(i))) <<
                        QString::number(qGreen(pixels.at(i))) <<
                        QString::number(qBlue(pixels.at(i)));
      
              strings << values;
          }
      
          return strings;
      
      }
      
      void WriteToCSV(const QList<QStringList>& pixels)
      {
          // Open csv-file
          QFile file("pixels.csv");
          file.open(QIODevice::Append | QIODevice::Text);
      
          // Write data to file
          QTextStream stream(&file);
          QString separator(",");
          for (int i = 0; i < pixels.size(); ++i)
          {
              stream << pixels.at(i).join(separator) << endl;
          }
      
          stream.flush();
          file.close();
      }
      
      QList<QStringList> ReadCSV()
      {
          // Open csv-file
          QFile file("pixels.csv");
          file.open(QIODevice::ReadOnly | QIODevice::Text);
      
          // Read data from file
          QTextStream stream(&file);
          QList<QStringList> data;
          QString separator(",");
          while (stream.atEnd() == false)
          {
              QString line = stream.readLine();
              data << line.split(separator);
          }
      
          file.close();
          return data;
      }
      
      void Print(const QList<QStringList>& data)
      {
          for (int i = 0; i < data.size(); ++i)
          {
              qDebug() << data.at(i).join(", ");
          }
      }
      
      int main()
      {
          QList<QRgb> pixels = GetPixels();
          QList<QStringList> pixelsStr = PixelsToStrings(pixels);
          WriteToCSV(pixelsStr);
      
          QList<QStringList> readData = ReadCSV();
          Print(readData);
      
          return 0;
      }
      

      This code is working fine on native compiler - Linux (ubuntu) but when cross compiling for raspberry pi, Errors facing -

      1. .Join member is missing in QStringList , there are other members like isEmpty etc also missing.
      2. .open - No matching member function for call to 'open'.

      If anyone faced similar issues and knows the solution, please share with me. It would be really appreciated.

      Similar post I found - https://forum.qt.io/topic/118482/qstringlist-missing-methods

      K Offline
      K Offline
      KroMignon
      wrote on 19 Oct 2020, 10:03 last edited by
      #2

      @RiyG22 said in QT cross compilation error for raspberry pi - QStringList and QFile members missing:

      when cross compiling for raspberry pi

      How did you install / setup RPi cross-compiling tools?

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

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RiyG22
        wrote on 19 Oct 2020, 10:09 last edited by
        #3

        @KroMignon , Thank you for your quick reply.
        I followed these below links and created a kit successfully -
        https://www.ics.com/blog/configuring-qt-creator-raspberry-pi
        https://wiki.qt.io/RaspberryPi2EGLFS

        K 1 Reply Last reply 19 Oct 2020, 10:41
        0
        • R RiyG22
          19 Oct 2020, 10:09

          @KroMignon , Thank you for your quick reply.
          I followed these below links and created a kit successfully -
          https://www.ics.com/blog/configuring-qt-creator-raspberry-pi
          https://wiki.qt.io/RaspberryPi2EGLFS

          K Offline
          K Offline
          KroMignon
          wrote on 19 Oct 2020, 10:41 last edited by
          #4

          @RiyG22 Which one did you use? Which Qt Version did you build?
          Have you try to build your project on RPi himself?

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

          R 1 Reply Last reply 19 Oct 2020, 10:59
          0
          • K KroMignon
            19 Oct 2020, 10:41

            @RiyG22 Which one did you use? Which Qt Version did you build?
            Have you try to build your project on RPi himself?

            R Offline
            R Offline
            RiyG22
            wrote on 19 Oct 2020, 10:59 last edited by
            #5

            @KroMignon ,
            Used One- https://wiki.qt.io/RaspberryPi2EGLFS
            Qt version - Qt 5.13.1
            No, I've not tried to build the project on RPI itself. I 've cross compiling the project without adding CSV file functionality and successfully run it on RPi.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              RiyG22
              wrote on 20 Oct 2020, 09:09 last edited by
              #6

              Solved the issue with disabling Clang code model.

              JonBJ 1 Reply Last reply 20 Oct 2020, 09:11
              1
              • R RiyG22
                20 Oct 2020, 09:09

                Solved the issue with disabling Clang code model.

                JonBJ Online
                JonBJ Online
                JonB
                wrote on 20 Oct 2020, 09:11 last edited by
                #7

                @RiyG22
                I don't know whether it also applies to your situation, but as of Ubuntu 20.04 you now have to additionally apt-get a clang8 package --- I forget the exact name, but you can Google --- to make clang work correctly.

                1 Reply Last reply
                1

                1/7

                19 Oct 2020, 09:55

                • Login

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