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. Accent Qt 5.0.2
Qt 6.11 is out! See what's new in the release blog

Accent Qt 5.0.2

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

    Hello,

    I work on Microsoft Visual Studio 2010 with the last service pack and I have a problem when I draw a QTreeView.
    The item have a strange character.

    For example this is what I do:
    @QStandardItem *qsInfos = new QStandardItem("Infos");
    sTexte = "Vérificateur"
    qsInfos->appendRow(new QStandardItem(sTexte.c_str()));@

    I tried
    @qsInfos->appendRow(new QStandardItem(QString::fromStdString(sTexte)));@

    @qsInfos->appendRow(new QStandardItem(QObject::tr(sTexte.c_str()));@

    But it didn't work, I have a strange character in the QTreeView

    1 Reply Last reply
    0
    • francescmmF Offline
      francescmmF Offline
      francescmm
      wrote on last edited by
      #2

      I think that could be a text encoding problem. Try to put in your application:

      @QTextCodec *utf8 = QTextCodec::codecForName("UTF-8");
      QTextCodec::setCodecForTr(utf8);
      QTextCodec::setCodecForCStrings(utf8);
      QTextCodec::setCodecForLocale(utf8);@

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kevin44115
        wrote on last edited by
        #3

        Thank you for your answer.

        @QTextCodec::setCodecForTr(utf8);
        QTextCodec::setCodecForCStrings(utf8);@

        I don't found this method in Qt 5.0.2.

        I tried

        @QTextCodec *utf8 = QTextCodec::codecForName("UTF-8");
        QTextCodec::setCodecForLocale(utf8);@

        But it didn't solved my problem.

        Another idea ?

        1 Reply Last reply
        0
        • francescmmF Offline
          francescmmF Offline
          francescmm
          wrote on last edited by
          #4

          Sorry for setCodecForCStrings, it is deprecated in Qt 5.0.2. Could you try to do this?

          @qsInfos->appendRow(new QStandardItem(QString::fromLatin1(sTexte)));@

          Despite it I think that could be a problem with your project/files encoding.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kevin44115
            wrote on last edited by
            #5

            Yes it's works.
            But I don't want to do this for all text.

            I tried in the constructor:

            @QTextCodec *codec = QTextCodec::codecForName("ISO 8859-1");
            QTextCodec::setCodecForLocale(codec);@

            But it didn't work

            1 Reply Last reply
            0
            • francescmmF Offline
              francescmmF Offline
              francescmm
              wrote on last edited by
              #6

              Take a look to "this forum topic":http://qt-project.org/forums/viewthread/17617. It could help you.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kevin44115
                wrote on last edited by
                #7

                Thanks for your help, it doesn't resolve my problem.
                My project is configure for "UTF8" encodage.

                Actualy I do

                @QString::fromLatin1(sTexte)@

                If anyone find a better solution

                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