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
    #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
                          • E Offline
                            E Offline
                            enaud84
                            wrote on last edited by
                            #21

                            this book is perfect! it start from zero :)
                            very thanks :)
                            [quote author="ddriver" date="1333401818"]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.[/quote]

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

                              I'm continued with my experiment:

                              @
                              #include <QtGui/QApplication>
                              #include "mainwindow.h"
                              #include <QPainter>

                              int main(int argc, char *argv[])
                              {
                              QApplication a(argc, argv);
                              MainWindow w;
                              w.show();
                              QImage myImage(120,120,QImage::Format_Mono);
                              QPainter painter( &myImage );

                              return a.exec&#40;&#41;;
                              

                              }
                              @
                              now i must draw a bitmap with a text that i write in a text box..

                              How I must proceed?

                              thanks

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

                                Let me quote myself:
                                [quote author="Andre" date="1333381873"]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? [/quote]

                                You're on the right way, but you might try to make slightly bigger strides before getting back here for more help...

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

                                  i'm a novice and so i call help to you for to do this little application just for study.. :)

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

                                    @painter.drawText(rect, Qt::AlignCenter, (textedit));@

                                    I not undstand: what is rect and after how take text from textedit on mainwindows.ui.?

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

                                      The documentation of the function that you choose to use, states (among a lot of other stuff):
                                      [quote]Draws the given text within the provided rectangle.[/quote]
                                      So, the rectangle you provide in rect is the area in which the text will be rendered. In your case, you will want to be the whole image, so you provide the rectangle your image provides for these purposes:
                                      @
                                      QString text;
                                      //text = .... (see below)
                                      painter.drawText(myImage.rect(), Qt::AlignCenter, text);
                                      @

                                      OK?

                                      So, now for what to put on line 2 of the sample above. So far, you have put all your rendering code in your main() function. You may want to re-think that. That has nothing to do with Qt, but everything with object oriented C++ programming in general.

                                      I guess the code for rendering should go in a function inside your MainWindow class. If you do so, you'll automatically have access to the textedit that you put on your main window.

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

                                        thanks Andre..
                                        I have a GUI project with:
                                        mainwindow.ui--> where i drawed a QLineEdit called textedit.
                                        mainwindow.h
                                        main.cpp
                                        mainwindow.cpp

                                        How to select textedit in mainwindow.ui instead of Qstring text?

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

                                          What did you try already. I already told you: we're not here to guide you Every. Single. Step. Of. The. Way.

                                          Did you start in that free book you were recommended already?

                                          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