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. How to check the first character of line from the text file in Qt
Forum Updated to NodeBB v4.3 + New Features

How to check the first character of line from the text file in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 460 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.
  • sankarapandiyanS Offline
    sankarapandiyanS Offline
    sankarapandiyan
    wrote on last edited by
    #1
    This post is deleted!
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @sankarapandiyan said in How to check the first character of line from the text file in Qt:

      now i want to send the first 3 line to that serial port and the letter start from h means its sends (seria.write ) to another serial port

      See QString::startsWith()

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      sankarapandiyanS 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @sankarapandiyan said in How to check the first character of line from the text file in Qt:

        now i want to send the first 3 line to that serial port and the letter start from h means its sends (seria.write ) to another serial port

        See QString::startsWith()

        sankarapandiyanS Offline
        sankarapandiyanS Offline
        sankarapandiyan
        wrote on last edited by
        #3

        @Christian-Ehrlicher Yes i want to read line by line first and after that if the string is = h means
        its need to write on the another serial port
        i tried this code but its not works

        
        QTextStream stream(&inputFile);
              while(!stream.atEnd()) {
              QString strline = stream.readLine();
              m_lines.append(strline + QString("\r\n"));
        if QString::stratsWith("h"){
          QString strline = stream.readLine();
              m_lines.append(strline + QString("\r\n"));
        }
        
              }
              }
              checkAndSendData();
        }
        
        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @sankarapandiyan said in How to check the first character of line from the text file in Qt:

          i tried this code but its not works

          First this code does not compile - so please don't say 'I tried this code' ...
          Second - this code does not write anything to any serial port.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          sankarapandiyanS 1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher

            @sankarapandiyan said in How to check the first character of line from the text file in Qt:

            i tried this code but its not works

            First this code does not compile - so please don't say 'I tried this code' ...
            Second - this code does not write anything to any serial port.

            sankarapandiyanS Offline
            sankarapandiyanS Offline
            sankarapandiyan
            wrote on last edited by
            #5
            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