Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. degree Celsius symbol not displayed in Qt QML
QtWS25 Last Chance

degree Celsius symbol not displayed in Qt QML

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 5 Posters 1.0k 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.
  • V Offline
    V Offline
    Vijay R. Gawade
    wrote on 26 Oct 2021, 11:25 last edited by Vijay R. Gawade
    #1

    I am using sqlite DB to store records
    In DB "High Temperature Alarm Setting Changed to %1°C++3" text stored in Table.

    I read record from DB in c++ class as follows:

    SqlQuery query;
    query.prepare("SELECT * FROM Events ORDER BY id DESC LIMIT 50 ");
    query.exec();
    
    QString msg
    	while(query.next()){
    		QString msg=query.value(3).toString();
    		qDebug()<<"msg="<<msg;
    		QStringList array = string.split("+");
    		QString sign=array[2].toInt()>0?"+":"-";        
    		QString trString = tr(QString(array[0]).replace("%1",sign+array[2]).toLocal8Bit());
    		qDebug()<<"trString="<<trString;
    	}
    

    // Output: ​"High Temperature Alarm Setting Changed to %1?C++3"
    // expected: "High Temperature Alarm Setting Changed to %1°C++3"

    In ubuntu 18, it works fine & displaying degree celsius symbol but in G&F Display device it shows "?" symbol intead of "°"

    Device we are using following device
    https://support.garz-fricke.com/projects/Santino/Linux-Yocto/Releases/yocto-jethro-santino-overview.htm

    Qt version: 5.9.4

    J 1 Reply Last reply 26 Oct 2021, 11:51
    0
    • V Offline
      V Offline
      Vijay R. Gawade
      wrote on 13 Nov 2021, 12:21 last edited by
      #7

      @JKSH said in degree Celsius symbol not displayed in Qt QML:

      toLocal8Bit

      Code is working correctly with toLocal8Bit() on another device with same bsp & h/w. Only one change is on my device I had updated bsp version & then downgrade it (for testing purpose) , In this process some lib/config may be not reset/remove correctly due to this representation problem comes.

      Now I have change toLocal8Bit() to toUtf8() and now it works on both devices.

      tr(QString(array[0]).replace("%1",sign+array[2]).toUtf8());
      

      Thanks to all for help

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sierdzio
        Moderators
        wrote on 26 Oct 2021, 11:32 last edited by
        #2

        Make sure your font has the degree symbol in it.

        (Z(:^

        1 Reply Last reply
        3
        • V Vijay R. Gawade
          26 Oct 2021, 11:25

          I am using sqlite DB to store records
          In DB "High Temperature Alarm Setting Changed to %1°C++3" text stored in Table.

          I read record from DB in c++ class as follows:

          SqlQuery query;
          query.prepare("SELECT * FROM Events ORDER BY id DESC LIMIT 50 ");
          query.exec();
          
          QString msg
          	while(query.next()){
          		QString msg=query.value(3).toString();
          		qDebug()<<"msg="<<msg;
          		QStringList array = string.split("+");
          		QString sign=array[2].toInt()>0?"+":"-";        
          		QString trString = tr(QString(array[0]).replace("%1",sign+array[2]).toLocal8Bit());
          		qDebug()<<"trString="<<trString;
          	}
          

          // Output: ​"High Temperature Alarm Setting Changed to %1?C++3"
          // expected: "High Temperature Alarm Setting Changed to %1°C++3"

          In ubuntu 18, it works fine & displaying degree celsius symbol but in G&F Display device it shows "?" symbol intead of "°"

          Device we are using following device
          https://support.garz-fricke.com/projects/Santino/Linux-Yocto/Releases/yocto-jethro-santino-overview.htm

          Qt version: 5.9.4

          J Offline
          J Offline
          JKSH
          Moderators
          wrote on 26 Oct 2021, 11:51 last edited by
          #3

          @Vijay-R-Gawade What is the purpose of calling toLocal8Bit()?

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JoeCFD
            wrote on 26 Oct 2021, 14:29 last edited by
            #4

            Use \302\260
            QString str_degree( "20\302\260C" );
            std::cout << " == " << qPrintable( str_degree ) << std::endl;

            K 1 Reply Last reply 27 Oct 2021, 06:52
            0
            • J JoeCFD
              26 Oct 2021, 14:29

              Use \302\260
              QString str_degree( "20\302\260C" );
              std::cout << " == " << qPrintable( str_degree ) << std::endl;

              K Offline
              K Offline
              KroMignon
              wrote on 27 Oct 2021, 06:52 last edited by
              #5

              @JoeCFD said in degree Celsius symbol not displayed in Qt QML:

              std::cout << " == " << qPrintable( str_degree ) << std::endl;

              I do not understand the problem:

              • Is it the log message output?
              • the output in QML?
              • the reading from SQL?

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

              J 1 Reply Last reply 27 Oct 2021, 15:33
              0
              • K KroMignon
                27 Oct 2021, 06:52

                @JoeCFD said in degree Celsius symbol not displayed in Qt QML:

                std::cout << " == " << qPrintable( str_degree ) << std::endl;

                I do not understand the problem:

                • Is it the log message output?
                • the output in QML?
                • the reading from SQL?
                J Offline
                J Offline
                JoeCFD
                wrote on 27 Oct 2021, 15:33 last edited by JoeCFD
                #6

                @KroMignon I load temperature with unit C from xml and add \302\260 to it when it is displayed.
                My code above is only for testing,

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  Vijay R. Gawade
                  wrote on 13 Nov 2021, 12:21 last edited by
                  #7

                  @JKSH said in degree Celsius symbol not displayed in Qt QML:

                  toLocal8Bit

                  Code is working correctly with toLocal8Bit() on another device with same bsp & h/w. Only one change is on my device I had updated bsp version & then downgrade it (for testing purpose) , In this process some lib/config may be not reset/remove correctly due to this representation problem comes.

                  Now I have change toLocal8Bit() to toUtf8() and now it works on both devices.

                  tr(QString(array[0]).replace("%1",sign+array[2]).toUtf8());
                  

                  Thanks to all for help

                  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