Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QString to QByteArray problem.

    General and Desktop
    4
    4
    240
    Loading More Posts
    • 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
      streetsoul last edited by streetsoul

      I want to sending data by UART communication.
      So add below code.

      QByteArray send_data;
      QString value = "100000000";
      send_data = value.toUtf8();
      port->write(send_data.data());

      In this case, when data receiving occured fail.

      But if setting the value variable as "10000000"
      The result is success. data receiving is success.

      How can I solve this problem???

      1 Reply Last reply Reply Quote 0
      • Fuel 0
        Fuel 0 last edited by

        Just use

        send_data.append(value.toUtf8());
        
        1 Reply Last reply Reply Quote 3
        • hskoglund
          hskoglund last edited by

          Hi, also you could check that both sides of the UART communication has the same parity settings.

          1 Reply Last reply Reply Quote 3
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Hi,

            No need for QString to be involved in this case.

            port->write("100000000"); should be enough.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • First post
              Last post