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. Analysing an icon editor application
Forum Updated to NodeBB v4.3 + New Features

Analysing an icon editor application

Scheduled Pinned Locked Moved Solved General and Desktop
36 Posts 6 Posters 8.9k Views 4 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.
  • mrjjM mrjj

    @J.Hilk

    Absolutely and also holding ctrl+alt + click to open in spit window is really handy.

    J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #15

    @mrjj Wait, what !? I wasn't aware of that! Very very handy!

    Thankfully with 4.4.1 my Creator doesnt bug out any longer when i have more than one window open. Previously any and all popups would no longer be shown. Aggravating but made me lookup and learn more shortcuts...


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    mrjjM 1 Reply Last reply
    0
    • J.HilkJ J.Hilk

      @mrjj Wait, what !? I wasn't aware of that! Very very handy!

      Thankfully with 4.4.1 my Creator doesnt bug out any longer when i have more than one window open. Previously any and all popups would no longer be shown. Aggravating but made me lookup and learn more shortcuts...

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #16

      @J.Hilk
      Yep, now i only wish for a key that can open/close all comment sections in a file :)

      1 Reply Last reply
      0
      • tomyT Offline
        tomyT Offline
        tomy
        wrote on last edited by tomy
        #17

        Guys, I don't need these (I knew F2). I don't want to know where such a function is written or not, it's like ctrl+F. I want the sequence of the statements which are executed from the beginning of the program until end. You can also read prior posts as well.

        In Visual Studio 2017 when I code in C++, I put the cursor on the first statement of the main function and press Ctrl + F10 (Run to Cursor). And by pressing F10 (for executing a statement) and F11 (for going into the body of a function), it goes through the statements in the same way as they are executed by the compiler. So I will be aware of the process being done from start (where I pressed ctrl + F10) until end.

        Since I'm rather new in Qt, for being able to understand the program correctly, I need to know how the whole program runs.
        I hope I've made it clear now what I'm looking for.

        J.HilkJ 1 Reply Last reply
        0
        • tomyT tomy

          Guys, I don't need these (I knew F2). I don't want to know where such a function is written or not, it's like ctrl+F. I want the sequence of the statements which are executed from the beginning of the program until end. You can also read prior posts as well.

          In Visual Studio 2017 when I code in C++, I put the cursor on the first statement of the main function and press Ctrl + F10 (Run to Cursor). And by pressing F10 (for executing a statement) and F11 (for going into the body of a function), it goes through the statements in the same way as they are executed by the compiler. So I will be aware of the process being done from start (where I pressed ctrl + F10) until end.

          Since I'm rather new in Qt, for being able to understand the program correctly, I need to know how the whole program runs.
          I hope I've made it clear now what I'm looking for.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #18

          @tomy mmh, ist that just a fancy way of setting a breakpoint and hitting F5 ? That you can do in QtCreator as well as in VS, even same short cuts.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          2
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #19

            Ah you ment while debugging.
            Just place break point and the call trace window will show the complete call tree.
            http://doc.qt.io/qtcreator/creator-debug-mode.html
            section Viewing Call Stack Trace

            1 Reply Last reply
            3
            • tomyT Offline
              tomyT Offline
              tomy
              wrote on last edited by tomy
              #20

              OK, I want to go through a program line-by-line or instruction-by-instruction. For that apparently I can use the debugger. For that the first thing is I think going to Window > Views. But Views is grayed out there!

              I also went to main.cpp and tried to trace the instructions by F10 and F11. This way, I only could go into the constructor by F11 on IconEditor iconEditor;. I still don't know how those several functions in iconeditor.cpp are called/used!

              0_1509027707561_Capture.PNG

              mrjjM C 2 Replies Last reply
              0
              • tomyT tomy

                OK, I want to go through a program line-by-line or instruction-by-instruction. For that apparently I can use the debugger. For that the first thing is I think going to Window > Views. But Views is grayed out there!

                I also went to main.cpp and tried to trace the instructions by F10 and F11. This way, I only could go into the constructor by F11 on IconEditor iconEditor;. I still don't know how those several functions in iconeditor.cpp are called/used!

                0_1509027707561_Capture.PNG

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #21

                @tomy

                • I still don't know how those several functions in iconeditor.cpp are called/used!

                Place break points in them and do the actions that triggers them.
                Then use F10/F11 to step around.
                Or use the Find Usage functions to see all places used.

                The debugger wont show you the functions call before they are actually executed.

                1 Reply Last reply
                1
                • tomyT tomy

                  OK, I want to go through a program line-by-line or instruction-by-instruction. For that apparently I can use the debugger. For that the first thing is I think going to Window > Views. But Views is grayed out there!

                  I also went to main.cpp and tried to trace the instructions by F10 and F11. This way, I only could go into the constructor by F11 on IconEditor iconEditor;. I still don't know how those several functions in iconeditor.cpp are called/used!

                  0_1509027707561_Capture.PNG

                  C Offline
                  C Offline
                  Charlie_Hdz
                  wrote on last edited by
                  #22

                  @tomy for your last comment.

                  I think that you might want to study the Qt Debugger a little longer.

                  1. Set breakpoints.
                  2. Press F5 to go directly to the breakpoint.
                    If the breakpoint is not entering, then the app flow won't arrive there.
                  3. You can enter you OWN function directly by using F11.
                  4. Somewhat, rebuild and build your solution.

                  Kind Regards

                  Enrique

                  Kind Regards,
                  Enrique Hernandez
                  gearstech.com.mx
                  chernandez@gearstech.com.mx

                  1 Reply Last reply
                  0
                  • tomyT Offline
                    tomyT Offline
                    tomy
                    wrote on last edited by tomy
                    #23

                    I put a break point on the first instruction of each function in iconeditor.cpp. Then went back to main.cpp on the line IconEditor iconEditor;, pressed F10.

                    The result: It goes to the break point of the constructor and after returning from that by iconEditor.setIconImage(QImage(":/images/mouse.png"));it goes to the void IconEditor::setIconImage(const QImage &newImage) function body. And then after returning from that to main.cpp, by iconEditor.show();
                    to QSize IconEditor::sizeHint() const function body. after that it returns to main.cpp and then neither F10 nor F11 does any action. By now I know how these two above functions are called but what about other functions!? :(

                    C 1 Reply Last reply
                    0
                    • tomyT tomy

                      I put a break point on the first instruction of each function in iconeditor.cpp. Then went back to main.cpp on the line IconEditor iconEditor;, pressed F10.

                      The result: It goes to the break point of the constructor and after returning from that by iconEditor.setIconImage(QImage(":/images/mouse.png"));it goes to the void IconEditor::setIconImage(const QImage &newImage) function body. And then after returning from that to main.cpp, by iconEditor.show();
                      to QSize IconEditor::sizeHint() const function body. after that it returns to main.cpp and then neither F10 nor F11 does any action. By now I know how these two above functions are called but what about other functions!? :(

                      C Offline
                      C Offline
                      Charlie_Hdz
                      wrote on last edited by
                      #24

                      @tomy

                      show function is the last function that you're calling...

                      Don't know your implementation, but there is the possibility to have cascade calls from function. Use only F11 to see all the called functions.

                      Kind Regards,

                      Enrique

                      Kind Regards,
                      Enrique Hernandez
                      gearstech.com.mx
                      chernandez@gearstech.com.mx

                      1 Reply Last reply
                      1
                      • tomyT Offline
                        tomyT Offline
                        tomy
                        wrote on last edited by
                        #25

                        I've provided all three files contents in the first post here. Please copy and paste them onto a project on your Qt Creator to see whether it's possible to know how other functions are called.

                        mrjjM 1 Reply Last reply
                        0
                        • tomyT tomy

                          I've provided all three files contents in the first post here. Please copy and paste them onto a project on your Qt Creator to see whether it's possible to know how other functions are called.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by mrjj
                          #26

                          @tomy
                          Hi
                          It always possible.
                          But a function like setWindowsTitle are from Qt and it wont step into that code as
                          the actual code is not included in the installation. only the binary result.

                          Maybe that is what confusing you ?

                          Also as @Charlie_Hdz says, you are only calling
                          iconEditor.setWindowTitle(QObject::tr("Icon Editor"));
                          iconEditor.setIconImage(QImage(":/images/mouse.png"));

                          so none of the other function are called, except those use by the 2 functions.

                          tomyT 1 Reply Last reply
                          2
                          • mrjjM mrjj

                            @tomy
                            Hi
                            It always possible.
                            But a function like setWindowsTitle are from Qt and it wont step into that code as
                            the actual code is not included in the installation. only the binary result.

                            Maybe that is what confusing you ?

                            Also as @Charlie_Hdz says, you are only calling
                            iconEditor.setWindowTitle(QObject::tr("Icon Editor"));
                            iconEditor.setIconImage(QImage(":/images/mouse.png"));

                            so none of the other function are called, except those use by the 2 functions.

                            tomyT Offline
                            tomyT Offline
                            tomy
                            wrote on last edited by
                            #27

                            @mrjj
                            Hi,
                            Please take a look at the functions below. When I press ctrl+R, the programs starts and execute all functions including these ones too. Do you know how and where in the code the following functions are called?

                               QColor penColor() const { return curColor; }
                               QImage iconImage() const { return image; }
                               int zoomFactor() const { return zoom; }
                               void setPenColor(const QColor &newColor);
                               void setZoomFactor(int newZoom);
                            
                               ~IconEditor();
                            
                            protected:
                               void mousePressEvent(QMouseEvent *event);
                               void mouseMoveEvent(QMouseEvent *event);
                               void paintEvent(QPaintEvent *event);
                            
                            private:
                               void setImagePixel(const QPoint &pos, bool opaque);
                               QRect pixelRect(int i, int j) const;
                            
                            mrjjM 1 Reply Last reply
                            0
                            • tomyT tomy

                              @mrjj
                              Hi,
                              Please take a look at the functions below. When I press ctrl+R, the programs starts and execute all functions including these ones too. Do you know how and where in the code the following functions are called?

                                 QColor penColor() const { return curColor; }
                                 QImage iconImage() const { return image; }
                                 int zoomFactor() const { return zoom; }
                                 void setPenColor(const QColor &newColor);
                                 void setZoomFactor(int newZoom);
                              
                                 ~IconEditor();
                              
                              protected:
                                 void mousePressEvent(QMouseEvent *event);
                                 void mouseMoveEvent(QMouseEvent *event);
                                 void paintEvent(QPaintEvent *event);
                              
                              private:
                                 void setImagePixel(const QPoint &pos, bool opaque);
                                 QRect pixelRect(int i, int j) const;
                              
                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #28

                              @tomy said in Analysing an icon editor application:

                              ctrl+R,

                              That is normal run. Not debug so no stepping or breakpoint active.

                              QColor penColor() const { return curColor; } // called when setting property
                              QImage iconImage() const { return image; } // called when asking for image
                              int zoomFactor() const { return zoom; } // called when u click stuff
                              void setPenColor(const QColor &newColor); / called when setting property
                              void setZoomFactor(int newZoom); // called when u click stuff

                              protected: // called on mouse use
                              void mousePressEvent(QMouseEvent *event); // called by qt
                              void mouseMoveEvent(QMouseEvent *event); // called by qt
                              void paintEvent(QPaintEvent *event);// called by qt

                              tomyT 1 Reply Last reply
                              3
                              • mrjjM mrjj

                                @tomy said in Analysing an icon editor application:

                                ctrl+R,

                                That is normal run. Not debug so no stepping or breakpoint active.

                                QColor penColor() const { return curColor; } // called when setting property
                                QImage iconImage() const { return image; } // called when asking for image
                                int zoomFactor() const { return zoom; } // called when u click stuff
                                void setPenColor(const QColor &newColor); / called when setting property
                                void setZoomFactor(int newZoom); // called when u click stuff

                                protected: // called on mouse use
                                void mousePressEvent(QMouseEvent *event); // called by qt
                                void mouseMoveEvent(QMouseEvent *event); // called by qt
                                void paintEvent(QPaintEvent *event);// called by qt

                                tomyT Offline
                                tomyT Offline
                                tomy
                                wrote on last edited by
                                #29

                                @mrjj

                                That is normal run. Not debug so no stepping or breakpoint active.

                                I know that. Just said that to make the issue clear, as a bigger shape.
                                I got the point for the functions except:

                                QColor penColor() const { return curColor; } // called when setting property
                                void setPenColor(const QColor &newColor); / called when setting property
                                QImage iconImage() const { return image; } // called when asking for image

                                Do you mean the three Q_PROPERTY used in the header file by "called when setting property"? If so, then how are they called when I don't use those Q_PROPERTYes? Because they seem useless, that is either I use or remove them the program runs and works well.

                                And about "called when asking for image", in what line is there an instruction that asks for the image?

                                mrjjM 1 Reply Last reply
                                0
                                • tomyT tomy

                                  @mrjj

                                  That is normal run. Not debug so no stepping or breakpoint active.

                                  I know that. Just said that to make the issue clear, as a bigger shape.
                                  I got the point for the functions except:

                                  QColor penColor() const { return curColor; } // called when setting property
                                  void setPenColor(const QColor &newColor); / called when setting property
                                  QImage iconImage() const { return image; } // called when asking for image

                                  Do you mean the three Q_PROPERTY used in the header file by "called when setting property"? If so, then how are they called when I don't use those Q_PROPERTYes? Because they seem useless, that is either I use or remove them the program runs and works well.

                                  And about "called when asking for image", in what line is there an instruction that asks for the image?

                                  mrjjM Offline
                                  mrjjM Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #30

                                  @tomy
                                  well its part of a larger system and are very usefull with rest of Qt
                                  http://doc.qt.io/qt-5/properties.html

                                  iconImage() is an access function and it seem its not used.
                                  Its normal to make access function for data user might want to read.
                                  One could also make the image variable public but that is bad design.

                                  tomyT 1 Reply Last reply
                                  2
                                  • mrjjM mrjj

                                    @tomy
                                    well its part of a larger system and are very usefull with rest of Qt
                                    http://doc.qt.io/qt-5/properties.html

                                    iconImage() is an access function and it seem its not used.
                                    Its normal to make access function for data user might want to read.
                                    One could also make the image variable public but that is bad design.

                                    tomyT Offline
                                    tomyT Offline
                                    tomy
                                    wrote on last edited by tomy
                                    #31

                                    @mrjj
                                    Thanks.

                                    very useful with rest of Qt

                                    I saw the page and found it a little advanced for me. In the case of this example, it's simply redundant but it's surely useful for the next stages of Qt when I study, if I've understood your talk above, correctly.

                                    That function is also useless here as of a few before-mentioned functions. I think the author has founded a right structure for uses like that but here has used only the needed functions.

                                    One question in this end, how do you know a method is called by Qt itself? By your experience or is there any clue?

                                    mrjjM jsulmJ 2 Replies Last reply
                                    0
                                    • tomyT tomy

                                      @mrjj
                                      Thanks.

                                      very useful with rest of Qt

                                      I saw the page and found it a little advanced for me. In the case of this example, it's simply redundant but it's surely useful for the next stages of Qt when I study, if I've understood your talk above, correctly.

                                      That function is also useless here as of a few before-mentioned functions. I think the author has founded a right structure for uses like that but here has used only the needed functions.

                                      One question in this end, how do you know a method is called by Qt itself? By your experience or is there any clue?

                                      mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #32

                                      @tomy
                                      Yes, its not always you use all access function at once but its part of the design
                                      to better to cope with changes later on.

                                      Well when i dont know a function , i press F1 on it (help) and if there is help
                                      its Qt function.
                                      Also, you can ask Creator to show all functions in a file and its then easy to see if part of
                                      an object or must come from other place.

                                      tomyT 1 Reply Last reply
                                      0
                                      • mrjjM mrjj

                                        @tomy
                                        Yes, its not always you use all access function at once but its part of the design
                                        to better to cope with changes later on.

                                        Well when i dont know a function , i press F1 on it (help) and if there is help
                                        its Qt function.
                                        Also, you can ask Creator to show all functions in a file and its then easy to see if part of
                                        an object or must come from other place.

                                        tomyT Offline
                                        tomyT Offline
                                        tomy
                                        wrote on last edited by
                                        #33

                                        @mrjj

                                        and if there is help
                                        its Qt function.

                                        And no need for our calling; it's called by the system (Qt). Yeah?

                                        Also, you can ask Creator to show all functions in a file and its then easy to see if part of
                                        an object or must come from other place.

                                        Did you mean again, using 'Find Usages' which is another appearance of ctrl+F to me?

                                        1 Reply Last reply
                                        0
                                        • tomyT tomy

                                          @mrjj
                                          Thanks.

                                          very useful with rest of Qt

                                          I saw the page and found it a little advanced for me. In the case of this example, it's simply redundant but it's surely useful for the next stages of Qt when I study, if I've understood your talk above, correctly.

                                          That function is also useless here as of a few before-mentioned functions. I think the author has founded a right structure for uses like that but here has used only the needed functions.

                                          One question in this end, how do you know a method is called by Qt itself? By your experience or is there any clue?

                                          jsulmJ Offline
                                          jsulmJ Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #34

                                          @tomy said in Analysing an icon editor application:

                                          how do you know a method is called by Qt itself?

                                          Well, it depends on the method. If you for example override an event handler in your own class derived from QWidget then it will be called by Qt. There is no simple answer to this question. Read Qt documentation and try to understand how Qt works. In general Qt can only call something it knows about (what belongs to Qt, like event handler) or what you connect to signals.

                                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          1 Reply Last reply
                                          1

                                          • Login

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