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
Forum Updated to NodeBB v4.3 + New Features

degree Celsius symbol not displayed in Qt QML

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 5 Posters 1.2k Views 2 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.
  • V Offline
    V Offline
    Vijay R. Gawade
    wrote on 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

    JKSHJ 1 Reply Last reply
    0
    • V Offline
      V Offline
      Vijay R. Gawade
      wrote on 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
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #2

        Make sure your font has the degree symbol in it.

        (Z(:^

        1 Reply Last reply
        3
        • V Vijay R. Gawade

          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

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on 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
          • JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #4

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

            KroMignonK 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

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

              KroMignonK Offline
              KroMignonK Offline
              KroMignon
              wrote on 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)

              JoeCFDJ 1 Reply Last reply
              0
              • KroMignonK KroMignon

                @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?
                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on 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 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