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] Menu & Window Caption - special chars aren't displaying correctly

[Solved] Menu & Window Caption - special chars aren't displaying correctly

Scheduled Pinned Locked Moved General and Desktop
37 Posts 6 Posters 26.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.
  • P Offline
    P Offline
    Peppy
    wrote on last edited by
    #1

    I have in caption and in menu special chars like "ľščťžýáíéúäň" - someone from this chars can't display correct in menu & window caption for exaple.: š,č,ž,ť...I don't have any idea how to correct this mistakes...

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Which platform are you using?

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Franzk
        wrote on last edited by
        #3

        Make sure you use the correct encoding when writing these strings. Your source file has to be encoded correctly, as should you convert correctly to QStrings.

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          My advice on this would be to not use those characters in your code at all. In your basic application, you could use English (which has no special characters). Then, you use Qt Linguist to translate your application to the language you require. Of course, you do need to

          make all user-visible strings translatable (good idea anyway)

          install the translator in your QApplication (see the "documentation":http://doc.qt.nokia.com/4.7/linguist-programmers.html here)

          build the .qm files from the .ts files

          distribute the .qm files with your application, or build them into the application as a resource

          1 Reply Last reply
          0
          • P Offline
            P Offline
            Peppy
            wrote on last edited by
            #5

            @Volker: Windows XP, Slovak Language Pack.
            @Franzk: Yes, I am not sure with encoding
            @Andre: That's not neccesary, it's just few strings (about 20)...

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              This sounds like an encoding issue. Do the strings display correctly on a QLabel?

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Peppy
                wrote on last edited by
                #7

                The same problem.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  Then it should be an encoding problem.

                  I'd suggest you convert the source files into UTF-8. Qt Creator can do this, if you use it.

                  Then add to your .pro file:

                  @
                  CODECFORTR = UTF-8
                  CODECFORSRC = UTF-8
                  @

                  And add to your main method:

                  @
                  #include <QTextCodec>

                  int main( int argc, char ** argv )
                  {
                  QApplication app(argc, argv);
                  QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
                  QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));

                  // your code goes here
                  

                  }
                  @

                  You could change UTF-8 to your ISO-8859-xxx version but then you might have problems with other characters, better make it UTF-8 if you set the codecs anyways.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Peppy
                    wrote on last edited by
                    #9

                    Didn't help to me.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #10

                      Can you create a small test program that demonstrates the behavior, then. Just a main method and a small class as GUI.

                      A screenshot of the test window would help too.

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • ? This user is from outside of this forum
                        ? This user is from outside of this forum
                        Guest
                        wrote on last edited by
                        #11

                        Saw a similar problem with the degree symbol ('\260' as a char). I recall the solution was related to which fonts were being used (Linux Font Server silently substituted some of them). Also hard-coding the needed symbol (hence the \260) was part of the solution.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #12

                          [quote author="Peppy" date="1304452100"]
                          @Andre: That's not neccesary, it's just few strings (about 20)...[/quote]
                          That was not the point. The point is that it would probably save you from all the encoding issues (including those that may arise if some other dev opens up the file later on in some random editor, and doesn't realize that that is important).

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            Peppy
                            wrote on last edited by
                            #13

                            I am back...so I have this KISS code:
                            @
                            #include <QtGui/QApplication>
                            #include <QtGui/QWidget>
                            #include <QtGui/QLabel>

                            int main(int argc, char *argv[])
                            {
                            QApplication a(argc, argv);

                            QWidget* window = new QWidget();
                                     window->setWindowTitle(QString("ľščťžýáíéäúňô"));
                                     window->resize(400,300);
                                     window->show();
                            
                            QLabel* label = new QLabel(window);
                                    label->move(100,100);
                                    label->setText(QString("ľščťžýáíéäúňô"));
                                    label->show();
                            
                            return a.exec&#40;&#41;;
                            

                            }
                            @
                            Nothing more. And this is result: !http://i56.tinypic.com/p93qq.png(http://i56.tinypic.com/p93qq.png);!

                            I don't know what's need to change...System font is Tahoma which includes special chars, probably this is an issue on application side...

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              andre
                              wrote on last edited by
                              #14

                              Try to follow Volker's suggestion that he posted 21 hours ago (the .pro file stuff and the encoding stuff in the main function).

                              1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                Peppy
                                wrote on last edited by
                                #15

                                I've tried, and this is result:

                                !http://i55.tinypic.com/2lx83s.png(http://i55.tinypic.com/2lx83s.png)!

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  Peppy
                                  wrote on last edited by
                                  #16

                                  My platform is: Windows XP Pro SP2 SK MUI (EN/RU); Qt 4.7.1

                                  1 Reply Last reply
                                  0
                                  • G Offline
                                    G Offline
                                    goetz
                                    wrote on last edited by
                                    #17

                                    [quote author="Peppy" date="1304530509"]I've tried, and this is result:[/quote]

                                    You must actually change the encoding of your file. If you use Qt Creator go to the project pane, then to editor settings and change the default encoding to UTF-8.

                                    For all your files that you have already: open them in Creator, go to menu Edit / Select Encoding... choose UTF-8 and click "save with encoding". This transforms all of your files to UTF-8 encoding.

                                    If you know how to handle the tool, you can use something like recode too, of course. Just make sure Creator reloads the files, if they're open. Otherwise it overwrites the converted files. Better close all files before you do the conversion, quit Creator and open it afterwards.

                                    http://www.catb.org/~esr/faqs/smart-questions.html

                                    1 Reply Last reply
                                    0
                                    • P Offline
                                      P Offline
                                      Peppy
                                      wrote on last edited by
                                      #18

                                      Now it works! Great! Thank you...

                                      1 Reply Last reply
                                      0
                                      • P Offline
                                        P Offline
                                        Peppy
                                        wrote on last edited by
                                        #19

                                        But it's unbelievable that awful system, why there's no set up option to set up encoding? Now I have to change all files...

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          andre
                                          wrote on last edited by
                                          #20

                                          A few posts ago, it was only a mini project with 20 odd strings...

                                          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