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. QString to QByteArray problem.
Qt 6.11 is out! See what's new in the release blog

QString to QByteArray problem.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 671 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
    streetsoul
    wrote on last edited by streetsoul
    #1

    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
    0
    • Fuel 0F Offline
      Fuel 0F Offline
      Fuel 0
      wrote on last edited by
      #2

      Just use

      send_data.append(value.toUtf8());
      
      1 Reply Last reply
      3
      • hskoglundH Offline
        hskoglundH Offline
        hskoglund
        wrote on last edited by
        #3

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

        1 Reply Last reply
        3
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          1

          • Login

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