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. [Solved] Qt 5.1 statusbar character encoding bug
Forum Updated to NodeBB v4.3 + New Features

[Solved] Qt 5.1 statusbar character encoding bug

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.2k 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.
  • E Offline
    E Offline
    eMixam
    wrote on last edited by
    #1

    Hello,

    I may have found a bug in the QStatusBar in Qt5.1.

    My locale is French and I'm trying to display accents : "éàêùç ..." and all of them appear as black "?" if I compile with Qt5.1.
    If I compile with Qt4.8.4 the accents appear.

    You can make the test, just create a new project application and add after "ui->setupUI(this)" :
    @ui->statusbar->showMessage("éàêùç");@

    Can you confirm it's a regression / bug or did I miss something ?

    Thanks in advance.

    EDIT : forgot to say that the others texts, used in QLabels are displaed correctly.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Hi,
      Is the exec-charset of your application is UTF-8?

      1 Reply Last reply
      0
      • E Offline
        E Offline
        eMixam
        wrote on last edited by
        #3

        I do think so since if I build my QString with QString::fromLatin1(), the accents are displayed correctly.

        What I don't understand is why do I need to specify it only for the QStatusBar ?
        In other QLabels and even in QML Text they are displayed correctly.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dbzhang800
          wrote on last edited by
          #4

          [quote author="eMixam" date="1374570249"]I do think so since if I build my QString with QString::fromLatin1(), the accents are displayed correctly.
          [/quote]
          It means that the exec charset of your application is latin1! So you need to use QLatin1String or QString::fromLatin1() to convert the string from char* to QString.

          [quote author="eMixam" date="1374570249"]
          What I don't understand is why do I need to specify it only for the QStatusBar ?
          In other QLabels and even in QML Text they are displayed correctly.[/quote]

          Are your sure that:

          @
          ui->label->setText("éàêùç");
          @

          works in your source code?

          1 Reply Last reply
          0
          • E Offline
            E Offline
            eMixam
            wrote on last edited by
            #5

            [quote author="1+1=2" date="1374571527"]
            It means that the exec charset of your application is latin1! So you need to use QLatin1String or QString::fromLatin1() to convert the string from char* to QString.[/quote]

            Okay, so QString is using UTF-8 as default hence the need to use QString::fromLatin1() ...

            [quote author="1+1=2" date="1374571527"]
            Are your sure that:

            @ui->label->setText("éàêùç");@

            works in your source code?[/quote]

            Nope, does not. This means that it's the Designer who does the conversion.
            I still don't know how the QtQuick part of my application does the conversion of units.

            Thanks for your help.

            EDIT : I know why the QtQuick part displays the accents : it takes its data from a XmlListModel and the XML file is encoded in UTF-8 :)

            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