Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Paint Symbol with drawText() method
Forum Updated to NodeBB v4.3 + New Features

Paint Symbol with drawText() method

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 4 Posters 5.5k 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.
  • V Offline
    V Offline
    Vetryaspa
    wrote on 5 Mar 2012, 11:30 last edited by
    #1

    Hi all,

    i have a problem to paint a text, the problem is not the painter but the text because i have to Write "€" symble and it was not write, compare a white rect or if i cast is toUtf8 compare wrong String.

    How i can paint it?

    regards

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 5 Mar 2012, 12:28 last edited by
      #2

      That's almost certainly due to wrong encoding of your source files. Please have a look for

      • CODECFORTR = UTF-8
        in qmake .pro files
      • CODECFORSRC = UTF-8
        in qmake .pro files
      • QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
        in your main method
      • QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
        in your main method

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

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vetryaspa
        wrote on 5 Mar 2012, 14:30 last edited by
        #3

        Volker I have to write this:

        @
        QPainter p;
        p.drawText(12, y+71, 100, 20, Qt::AlignLeft, QString("€"));@

        Now you saw my code, do you think it could be semplified?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Scylla
          wrote on 5 Mar 2012, 17:52 last edited by
          #4

          I'm using this:
          @ QPainter p;
          p.drawText(12, y+71, 100, 20, Qt::AlignLeft, QString::fromUtf8("€"));
          @

          The source file you have to save as utf8!

          1 Reply Last reply
          0
          • V Offline
            V Offline
            Vetryaspa
            wrote on 6 Mar 2012, 08:28 last edited by
            #5

            not paint too...

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on 6 Mar 2012, 09:22 last edited by
              #6

              If you just get a rectangle in the place of the character you expected that hints to either the conversion being wrong (output the value of the QChar and compare that to the unicode tables to verify this is not the case) or that the font does not contain the requested symbol.

              1 Reply Last reply
              0
              • V Offline
                V Offline
                Vetryaspa
                wrote on 6 Mar 2012, 09:47 last edited by
                #7

                [quote author="Tobias Hunger" date="1331025740"]If you just get a rectangle in the place of the character you expected that hints to either the conversion being wrong (output the value of the QChar and compare that to the unicode tables to verify this is not the case) or that the font does not contain the requested symbol.[/quote]

                then? how i have to do? cange the method to see if the code is not UTF8 but latin 1 o other?

                1 Reply Last reply
                0

                5/7

                6 Mar 2012, 08:28

                • Login

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