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

°C displayed as °C

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 6.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.
  • K Offline
    K Offline
    ken536
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      AcerExtensa
      wrote on last edited by
      #2

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

      God is Real unless explicitly declared as Integer.

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

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

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

          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
          0
          • G Offline
            G Offline
            GentooXativa
            wrote on last edited by
            #5

            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
            0
            • K Offline
              K Offline
              ken536
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • A Offline
                A Offline
                AcerExtensa
                wrote on last edited by
                #7

                Please add [SOLVED] to topic subject.

                God is Real unless explicitly declared as Integer.

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  ken536
                  wrote on last edited by
                  #8

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

                  Adding trUtf8 here to s doesn't work..

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

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

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      ken536
                      wrote on last edited by
                      #10

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

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        AcerExtensa
                        wrote on last edited by
                        #11

                        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
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved