Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

    °C displayed as °C

    General and Desktop
    4
    11
    5366
    Loading More Posts
    • 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
      ken536 last edited by

      When I use setText for a label like this:
      @ui->label_5->setText("°C");@
      It is displayed as:
      @°C@

      If I set °C in Qt Designer in the form editor, everything is displayed as it should.

      Why is this happening?

      1 Reply Last reply Reply Quote 0
      • A
        AcerExtensa last edited by

        try this:
        @ui->label_5->setText(tr("°C"));@

        God is Real unless explicitly declared as Integer.

        1 Reply Last reply Reply Quote 0
        • K
          ken536 last edited by

          Nope doesn't work.
          tr is for translating, why do you think it works for this?

          1 Reply Last reply Reply Quote 0
          • A
            AcerExtensa last edited by

            See "here":http://qt-project.org/doc/qt-4.8/qobject.html#trUtf8 ...

            God is Real unless explicitly declared as Integer.

            1 Reply Last reply Reply Quote 0
            • G
              GentooXativa last edited by

              Maybe you are saving your files with a wrong enconding? Check it at Options -> Text Editor

              Jose Vicente Giner Sanchez - Senior Mobile Developer

              www.gigigo.com

              C/ Dr. Zamenhof 36bis, 1ºA 28027 Madrid
              T: +34 917431436

              1 Reply Last reply Reply Quote 0
              • K
                ken536 last edited by

                Changing Encoding doesn't make any changes. TRUTF8 does the job :)

                1 Reply Last reply Reply Quote 0
                • A
                  AcerExtensa last edited by

                  Please add [SOLVED] to topic subject.

                  God is Real unless explicitly declared as Integer.

                  1 Reply Last reply Reply Quote 0
                  • K
                    ken536 last edited by

                    @
                    void MLineEdit::setLblText2(QString s )
                    {
                    label2->setText(s);
                    }
                    @

                    Adding trUtf8 here to s doesn't work..

                    1 Reply Last reply Reply Quote 0
                    • A
                      andre last edited by

                      Of course not, it only works with static text. You'll have to do the translation wherever s originates.

                      1 Reply Last reply Reply Quote 0
                      • K
                        ken536 last edited by

                        It is an Custom Widget:
                        Q_PROPERTY( QString Unit READ readLblText2 WRITE setLblText2 DESIGNABLE true SCRIPTABLE true STORED true )

                        1 Reply Last reply Reply Quote 0
                        • A
                          AcerExtensa last edited by

                          should look like this:

                          @
                          this->setLblText2(trUtf8("°C"));

                          void MLineEdit::setLblText2(QString s )
                          {
                          label2->setText(s);
                          }
                          @

                          God is Real unless explicitly declared as Integer.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post