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. Adding QChar into a QString
Forum Updated to NodeBB v4.3 + New Features

Adding QChar into a QString

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 912 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.
  • A Offline
    A Offline
    agmar
    wrote on 9 Feb 2023, 09:41 last edited by
    #1

    Hi,
    just a simple problem here, any obvious solution?
    3a2ed812-090f-4414-987d-4d44fb4aa67c-image.png ```
    code_text

    J 1 Reply Last reply 9 Feb 2023, 09:44
    0
    • A agmar
      9 Feb 2023, 10:18

      @jsulm yes , QChar allows me to add bytes in hex which should be sent out as a single message, changing it to QString doesnot seem to help,
      mSpeed and mAddress are both declared as QChar above...

      void MainWindow::writeSerial()
       {
         QString message;
         std::QString message = QChar(mSpeed) + QChar(mAddress);
           qDebug() << message;
      
       }
      
      

      error: ‘QString’ is not a member of ‘std’; did you mean ‘wstring’?
      88 | std::QString message = QChar(mSpeed) + QChar(mAddress);
      | ^~~~~~~
      | wstring

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 9 Feb 2023, 11:10 last edited by jsulm 2 Sept 2023, 11:13
      #8

      @agmar said in Adding QChar into a QString:

      void MainWindow::writeSerial()
      {
      QString message;
      std::QString message = QChar(mSpeed) + QChar(mAddress);
      qDebug() << message;

      }

      Come on, it is self explanatory:

      void MainWindow::writeSerial()
      {
          QString message = QChar(mSpeed) + QChar(mAddress);
          qDebug() << message;
      }
      

      And I actually suggested:

      void MainWindow::writeSerial()
      {
          QString message = QChar(mSpeed);
          message += QChar(mAddress);
          qDebug() << message;
      }
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 9 Feb 2023, 11:15
      3
      • A agmar
        9 Feb 2023, 09:41

        Hi,
        just a simple problem here, any obvious solution?
        3a2ed812-090f-4414-987d-4d44fb4aa67c-image.png ```
        code_text

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 9 Feb 2023, 09:44 last edited by
        #2

        @agmar What should the result be if you add a char to a char?
        First add mSpeed to the string and afterwards mAddress...

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        J 1 Reply Last reply 9 Feb 2023, 09:48
        0
        • J jsulm
          9 Feb 2023, 09:44

          @agmar What should the result be if you add a char to a char?
          First add mSpeed to the string and afterwards mAddress...

          J Offline
          J Offline
          JonB
          wrote on 9 Feb 2023, 09:48 last edited by
          #3

          @jsulm said in Adding QChar into a QString:

          What should the result be if you add a char to a char?

          That is a good question. What is the answer? :) QChar does not define a + operator, I don't know what the "ambiguous" warning here is telling us?

          J 1 Reply Last reply 9 Feb 2023, 09:51
          0
          • J JonB
            9 Feb 2023, 09:48

            @jsulm said in Adding QChar into a QString:

            What should the result be if you add a char to a char?

            That is a good question. What is the answer? :) QChar does not define a + operator, I don't know what the "ambiguous" warning here is telling us?

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 9 Feb 2023, 09:51 last edited by
            #4

            @JonB Would be good to see the whole error message.
            But as long as people post code and error messages as images (for whatever reason, it is way easier to copy paste text than creating and posting a screen shot) which are cut jsut where it becomes interesting...

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            A 1 Reply Last reply 9 Feb 2023, 09:58
            1
            • J jsulm
              9 Feb 2023, 09:51

              @JonB Would be good to see the whole error message.
              But as long as people post code and error messages as images (for whatever reason, it is way easier to copy paste text than creating and posting a screen shot) which are cut jsut where it becomes interesting...

              A Offline
              A Offline
              agmar
              wrote on 9 Feb 2023, 09:58 last edited by
              #5

              @jsulm Ok , here is the whole thing .

              b2afd334-6205-450a-8ea6-828ccd05cbe0-image.png

              It does not let me copy the error message tho.

              J 1 Reply Last reply 9 Feb 2023, 10:00
              0
              • A agmar
                9 Feb 2023, 09:58

                @jsulm Ok , here is the whole thing .

                b2afd334-6205-450a-8ea6-828ccd05cbe0-image.png

                It does not let me copy the error message tho.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 9 Feb 2023, 10:00 last edited by
                #6

                @agmar Is there a reason why you use std::string and QChar?
                Why don't you use QString?
                Errors/warnings can be copied in the tab at the bottom.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                A 1 Reply Last reply 9 Feb 2023, 10:18
                1
                • J jsulm
                  9 Feb 2023, 10:00

                  @agmar Is there a reason why you use std::string and QChar?
                  Why don't you use QString?
                  Errors/warnings can be copied in the tab at the bottom.

                  A Offline
                  A Offline
                  agmar
                  wrote on 9 Feb 2023, 10:18 last edited by
                  #7

                  @jsulm yes , QChar allows me to add bytes in hex which should be sent out as a single message, changing it to QString doesnot seem to help,
                  mSpeed and mAddress are both declared as QChar above...

                  void MainWindow::writeSerial()
                   {
                     QString message;
                     std::QString message = QChar(mSpeed) + QChar(mAddress);
                       qDebug() << message;
                  
                   }
                  
                  

                  error: ‘QString’ is not a member of ‘std’; did you mean ‘wstring’?
                  88 | std::QString message = QChar(mSpeed) + QChar(mAddress);
                  | ^~~~~~~
                  | wstring

                  J 1 Reply Last reply 9 Feb 2023, 11:10
                  0
                  • A agmar
                    9 Feb 2023, 10:18

                    @jsulm yes , QChar allows me to add bytes in hex which should be sent out as a single message, changing it to QString doesnot seem to help,
                    mSpeed and mAddress are both declared as QChar above...

                    void MainWindow::writeSerial()
                     {
                       QString message;
                       std::QString message = QChar(mSpeed) + QChar(mAddress);
                         qDebug() << message;
                    
                     }
                    
                    

                    error: ‘QString’ is not a member of ‘std’; did you mean ‘wstring’?
                    88 | std::QString message = QChar(mSpeed) + QChar(mAddress);
                    | ^~~~~~~
                    | wstring

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 9 Feb 2023, 11:10 last edited by jsulm 2 Sept 2023, 11:13
                    #8

                    @agmar said in Adding QChar into a QString:

                    void MainWindow::writeSerial()
                    {
                    QString message;
                    std::QString message = QChar(mSpeed) + QChar(mAddress);
                    qDebug() << message;

                    }

                    Come on, it is self explanatory:

                    void MainWindow::writeSerial()
                    {
                        QString message = QChar(mSpeed) + QChar(mAddress);
                        qDebug() << message;
                    }
                    

                    And I actually suggested:

                    void MainWindow::writeSerial()
                    {
                        QString message = QChar(mSpeed);
                        message += QChar(mAddress);
                        qDebug() << message;
                    }
                    

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    A 1 Reply Last reply 9 Feb 2023, 11:15
                    3
                    • J jsulm
                      9 Feb 2023, 11:10

                      @agmar said in Adding QChar into a QString:

                      void MainWindow::writeSerial()
                      {
                      QString message;
                      std::QString message = QChar(mSpeed) + QChar(mAddress);
                      qDebug() << message;

                      }

                      Come on, it is self explanatory:

                      void MainWindow::writeSerial()
                      {
                          QString message = QChar(mSpeed) + QChar(mAddress);
                          qDebug() << message;
                      }
                      

                      And I actually suggested:

                      void MainWindow::writeSerial()
                      {
                          QString message = QChar(mSpeed);
                          message += QChar(mAddress);
                          qDebug() << message;
                      }
                      
                      A Offline
                      A Offline
                      agmar
                      wrote on 9 Feb 2023, 11:15 last edited by
                      #9

                      @jsulm

                      That did it, thank you, i am just new to this, is all

                      1 Reply Last reply
                      0
                      • A agmar has marked this topic as solved on 9 Feb 2023, 11:15

                      1/9

                      9 Feb 2023, 09:41

                      • Login

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