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. Little aplication that translate a string in Arabic and after save this Label in BMP
Forum Updated to NodeBB v4.3 + New Features

Little aplication that translate a string in Arabic and after save this Label in BMP

Scheduled Pinned Locked Moved General and Desktop
28 Posts 3 Posters 9.7k 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.
  • E Offline
    E Offline
    enaud84
    wrote on last edited by
    #1

    Hi all,
    I'm new in C++/QT and i need your help because this is my first application:
    I must make an application in Arabic that translates a text string, then:
    INPUT -> Text Box

    OUTPUT -> Label Arial 8
    After this Label i must be exporting as BMP image..

    There is an example where i can view source code?
    thanks for help..

    1 Reply Last reply
    0
    • F Offline
      F Offline
      felipe.c.sousa
      wrote on last edited by
      #2

      do you will use the object "tr". but i never use that...

      From all, to all.

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

        How do you think you'll implement the translation part? I mean: do you have a dictionary or something available?

        The rendering to an image is the simple part... Just create a QImage, create a QPainter on that, and render your Arabic string using QPainter::paintText()

        1 Reply Last reply
        0
        • F Offline
          F Offline
          felipe.c.sousa
          wrote on last edited by
          #4

          using this object you can translate some languages for the Qt.

          From all, to all.

          1 Reply Last reply
          0
          • E Offline
            E Offline
            enaud84
            wrote on last edited by
            #5

            Thanks for your answer.
            I don't know how implement the traslation part.. A dictionary is ok.. But the problem is that in Arabic the shape of the letters change depending on the next letter, for example:

            "student" is طالب but it is formed by this letter:
            ط ا ل ب
            Note like change form for example this: ل --> لب

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

              But that is not your problem. Let Qt's text renderer worry about the text shapes... AFAIK, it is quite good at doing that.

              1 Reply Last reply
              0
              • E Offline
                E Offline
                enaud84
                wrote on last edited by
                #7

                Where is text renderer documentation?
                Do you have an example for this?
                I must export Arabic Label on a BMP file like ARAB1.bmp..

                thanks

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

                  [quote author="Andre" date="1333378587"]The rendering to an image is the simple part... Just create a QImage, create a QPainter on that, and render your Arabic string using QPainter::paintText()[/quote]

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    enaud84
                    wrote on last edited by
                    #9

                    Sorry.. but i'm a newbie in QT can you create for me a little application with this operations?
                    After i study your example for training... I want to learn QT and i want start from this first application..

                    Please :)

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

                      Sorry, no. I'm not going to do your homework for you. However, if why don't you just give it a (serious) try, and post your code when you get stuck? I'm sure somebody, perhaps myself, will be willing to help you out then. But you have to show that you're willing to put in effort of your own first.

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        enaud84
                        wrote on last edited by
                        #11

                        ok you can guide me step by step? Not is my housework :) i'm only a pensioner who wants to learn QT :D

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

                          [quote author="enaud84" date="1333380451"]ok you can guide me step by step?[/quote]

                          Why don't you give it a try and get started? We're not here to hold your hand every baby step of the way, but in general, we're a friendly bunch that are ready to help you. I already gave you a pointer on where to get started for the rendering stuff: [[doc:QImage]]. Note that that class also supports saving to file, including .bmp files (through a plugin, but that's of secundairy importance right now).

                          1 Reply Last reply
                          0
                          • E Offline
                            E Offline
                            enaud84
                            wrote on last edited by
                            #13

                            ok.. then start with :
                            @
                            #include <QtGui/QApplication>
                            #include "mainwindow.h"
                            #include <QPainter>

                            int main(int argc, char *argv[])
                            {
                            QApplication a(argc, argv);
                            MainWindow w;
                            w.show();
                            QImage myImage;

                            return a.exec(&#41;;
                            

                            }
                            @
                            to be continued..

                            edit: please use @ tags around code sections; Andre

                            1 Reply Last reply
                            0
                            • E Offline
                              E Offline
                              enaud84
                              wrote on last edited by
                              #14

                              now how create a Painter on that?

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

                                [[doc:QPainter]] only has one constructor that looks relevant... See if you can spot it as well. For better understanding, try if you can find out what QImage actually is, what class it inherits from.

                                1 Reply Last reply
                                0
                                • E Offline
                                  E Offline
                                  enaud84
                                  wrote on last edited by
                                  #16

                                  I think:

                                  @
                                  QPainter painter( &myImage );
                                  @

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

                                    OK, great. So now you have a QPainter on your QImage. Time to use that painter for something useful, right. Can you spot a useful method for painting text in the QPainter documentation?

                                    Perhaps you should give your image a size too... It is hard to paint if your canvas is too small, after all.

                                    1 Reply Last reply
                                    0
                                    • E Offline
                                      E Offline
                                      enaud84
                                      wrote on last edited by
                                      #18

                                      Hi,
                                      how set size of Image?
                                      I not find method for painting text in the QPainter documentation :(

                                      Thanks

                                      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
                                        #19

                                        enaud84 - I don't think what you people are doing in this threat is going to work any time soon. If your English is decent go and read a book on Qt, it will take you a while but you will actually learn something and be able to develop on your own without needing to be pushed every step of the way.

                                        Here is a link to a GOOD and FREE book on programming with Qt, it also contains the basics of C++ so it is a very good learning resource:
                                        http://ptgmedia.pearsoncmg.com/images/9780131879058/downloads/0131879057_Ezust_book.pdf

                                        As you get familiar with C++ and Qt you will find it much easier to work with the Qt documentation as well. I can tell you cannot get your way around the Qt DOC since you claim you cannot find a QPainter method for drawing text, and there is a whole bunch of overloads of the drawText() method.

                                        Good luck, be patient and consistent and you will be rewarded.

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

                                          [quote author="enaud84" date="1333400351"]Hi,
                                          how set size of Image?
                                          I not find method for painting text in the QPainter documentation :(

                                          Thanks[/quote]
                                          No, I understand that. But you would not expect to control the size of a real painting canvas via your brush or pencil either, right? Perhaps you should look at the [[doc:QImage]] documentation for a way to set the size of the image...

                                          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