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. A double buffering project
QtWS25 Last Chance

A double buffering project

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 3 Posters 4.3k Views
  • 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.
  • T Offline
    T Offline
    tomy
    wrote on 21 Nov 2017, 15:32 last edited by
    #1

    Hi,

    In this double buffering example, I've created the project this way:
    Creating a Plotter.h and writing its code onto it. Then adding another file Plotter.cpp to the corresponding project. The rest is adding the main.cpp file and running qMake for creating the .pro file. And finally running the project.

    I think it's not the way you would create that project and it's old-fashioned and also has problems (like not being able for the project to know the Qt built-in classes/functions).

    What is the way you use for creating projects like this?

    Another question is: below the first code on that link, it says: "We also reimplement minimumSizeHint() and sizeHint() from QWidget".
    How do we know if there is a built-in function like minimumSizeHint() or sizeHint() here, to use the word 'reimplementation' for that?

    Thanks.

    J 1 Reply Last reply 21 Nov 2017, 16:01
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 21 Nov 2017, 15:49 last edited by mrjj
      #2

      Hi
      You could create a normal GUI project with mainwindow (using the wizard)
      The "Add New" option, you get clicking on a project top, then allows
      you to add .h and .cpp for a custom widget automatically.
      ( which plotter seems to be)

      alt text

      and then after getting the default project ( right click top of project )
      alt text

      alt text

      For

      • We also reimplement minimumSizeHint() and sizeHint() from QWidget".

      You know from the base class you use for the custom widget.
      Anything marked virtual can be "reimplemented"

      T 1 Reply Last reply 22 Nov 2017, 14:31
      3
      • T tomy
        21 Nov 2017, 15:32

        Hi,

        In this double buffering example, I've created the project this way:
        Creating a Plotter.h and writing its code onto it. Then adding another file Plotter.cpp to the corresponding project. The rest is adding the main.cpp file and running qMake for creating the .pro file. And finally running the project.

        I think it's not the way you would create that project and it's old-fashioned and also has problems (like not being able for the project to know the Qt built-in classes/functions).

        What is the way you use for creating projects like this?

        Another question is: below the first code on that link, it says: "We also reimplement minimumSizeHint() and sizeHint() from QWidget".
        How do we know if there is a built-in function like minimumSizeHint() or sizeHint() here, to use the word 'reimplementation' for that?

        Thanks.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 21 Nov 2017, 16:01 last edited by
        #3

        @tomy said in A double buffering project:

        How do we know if there is a built-in function like minimumSizeHint() or sizeHint() here, to use the word 'reimplementation' for that?

        From Qt documentation

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

        1 Reply Last reply
        2
        • M mrjj
          21 Nov 2017, 15:49

          Hi
          You could create a normal GUI project with mainwindow (using the wizard)
          The "Add New" option, you get clicking on a project top, then allows
          you to add .h and .cpp for a custom widget automatically.
          ( which plotter seems to be)

          alt text

          and then after getting the default project ( right click top of project )
          alt text

          alt text

          For

          • We also reimplement minimumSizeHint() and sizeHint() from QWidget".

          You know from the base class you use for the custom widget.
          Anything marked virtual can be "reimplemented"

          T Offline
          T Offline
          tomy
          wrote on 22 Nov 2017, 14:31 last edited by tomy
          #4

          @mrjj
          Hi,

          My base class wasn't QMainWindow. My class name was Plotter and the base class was QWidget, so I chose this in the Class Information window as the base class. There are three as base classes: QMainWindow, QWidget and QDialog. But what if a project's base class isn't any of them? Is the solution modifying the code afterwards?

          I unchecked the check box Generate form and Next and Finish. Now I have the following. Is it also a right way for creating that project in your opinion please?

          0_1511360804908_Capture.PNG

          You know from the base class you use for the custom widget.

          I went for Protected Functions section of QWidget (my base class in this example) on Help, and saw neither minimumSizeHint() nor sizeHint()! :(

          Anything marked virtual can be "reimplemented"

          As well as, neither of those two are under protected scope, but public, as shown above.

          J 1 Reply Last reply 22 Nov 2017, 15:12
          0
          • T tomy
            22 Nov 2017, 14:31

            @mrjj
            Hi,

            My base class wasn't QMainWindow. My class name was Plotter and the base class was QWidget, so I chose this in the Class Information window as the base class. There are three as base classes: QMainWindow, QWidget and QDialog. But what if a project's base class isn't any of them? Is the solution modifying the code afterwards?

            I unchecked the check box Generate form and Next and Finish. Now I have the following. Is it also a right way for creating that project in your opinion please?

            0_1511360804908_Capture.PNG

            You know from the base class you use for the custom widget.

            I went for Protected Functions section of QWidget (my base class in this example) on Help, and saw neither minimumSizeHint() nor sizeHint()! :(

            Anything marked virtual can be "reimplemented"

            As well as, neither of those two are under protected scope, but public, as shown above.

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 22 Nov 2017, 15:12 last edited by
            #5

            @tomy said in A double buffering project:

            I went for Protected Functions section of QWidget (my base class in this example) on Help, and saw neither minimumSizeHint() nor sizeHint()! :(

            Really?
            Here it is: http://doc.qt.io/qt-5/qwidget.html#minimumSizeHint-prop and http://doc.qt.io/qt-5/qwidget.html#sizeHint-prop

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

            T 1 Reply Last reply 22 Nov 2017, 15:57
            1
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 22 Nov 2017, 15:15 last edited by
              #6

              Hi
              yes, its fine way.
              Besides those u can select in drop down, you can write a custom
              name in edit just below.
              However, if often better to use QWidget and just change classname 2 places if
              its not QWidget as else the constructor is not fully created. ( with custom name)

              1 Reply Last reply
              1
              • J jsulm
                22 Nov 2017, 15:12

                @tomy said in A double buffering project:

                I went for Protected Functions section of QWidget (my base class in this example) on Help, and saw neither minimumSizeHint() nor sizeHint()! :(

                Really?
                Here it is: http://doc.qt.io/qt-5/qwidget.html#minimumSizeHint-prop and http://doc.qt.io/qt-5/qwidget.html#sizeHint-prop

                T Offline
                T Offline
                tomy
                wrote on 22 Nov 2017, 15:57 last edited by
                #7

                @jsulm

                Really?

                Yes.

                0_1511366182763_1.PNG

                0_1511366204987_2.PNG

                So why aren't they on the Help menu!?

                M 1 Reply Last reply 22 Nov 2017, 16:04
                0
                • T tomy
                  22 Nov 2017, 15:57

                  @jsulm

                  Really?

                  Yes.

                  0_1511366182763_1.PNG

                  0_1511366204987_2.PNG

                  So why aren't they on the Help menu!?

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 22 Nov 2017, 16:04 last edited by
                  #8

                  @tomy
                  But they are ?!
                  alt text

                  T 1 Reply Last reply 22 Nov 2017, 16:12
                  0
                  • M mrjj
                    22 Nov 2017, 16:04

                    @tomy
                    But they are ?!
                    alt text

                    T Offline
                    T Offline
                    tomy
                    wrote on 22 Nov 2017, 16:12 last edited by tomy
                    #9

                    @mrjj
                    Would you Open it in Help mode?
                    I pressed F1 on QWidget.

                    EDITED:

                    I found them. They are on Public functions (not Protected!) :(
                    So we can re-implement public functions too!

                    M 1 Reply Last reply 22 Nov 2017, 16:27
                    0
                    • T tomy
                      22 Nov 2017, 16:12

                      @mrjj
                      Would you Open it in Help mode?
                      I pressed F1 on QWidget.

                      EDITED:

                      I found them. They are on Public functions (not Protected!) :(
                      So we can re-implement public functions too!

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 22 Nov 2017, 16:27 last edited by
                      #10

                      @tomy
                      Yes, its not important if placed under public, protected, private.
                      Its the virtual keyword that is important.
                      That is a key feature of c++.
                      It allows polymorphism.
                      http://www.cplusplus.com/doc/tutorial/polymorphism/

                      T 1 Reply Last reply 22 Nov 2017, 16:34
                      3
                      • M mrjj
                        22 Nov 2017, 16:27

                        @tomy
                        Yes, its not important if placed under public, protected, private.
                        Its the virtual keyword that is important.
                        That is a key feature of c++.
                        It allows polymorphism.
                        http://www.cplusplus.com/doc/tutorial/polymorphism/

                        T Offline
                        T Offline
                        tomy
                        wrote on 22 Nov 2017, 16:34 last edited by
                        #11

                        @mrjj
                        OK, thanks.

                        M 1 Reply Last reply 22 Nov 2017, 16:41
                        0
                        • T tomy
                          22 Nov 2017, 16:34

                          @mrjj
                          OK, thanks.

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 22 Nov 2017, 16:41 last edited by
                          #12

                          @tomy
                          Its a good concept to master.
                          It allows to have many types and have them in a list mixed.
                          and instead of having to do to

                          if ( current.type == TypeX )
                          call TypeX_Something
                          if ( current.type == TypeY )
                          call TypeY_Something
                          ...

                          the compiler will do that for you and you can just call

                          TypeX->Something

                          and compiler have made sure its correct type you actually call on.

                          So its used in many cases to achieve good design.

                          T 1 Reply Last reply 22 Nov 2017, 16:48
                          0
                          • M mrjj
                            22 Nov 2017, 16:41

                            @tomy
                            Its a good concept to master.
                            It allows to have many types and have them in a list mixed.
                            and instead of having to do to

                            if ( current.type == TypeX )
                            call TypeX_Something
                            if ( current.type == TypeY )
                            call TypeY_Something
                            ...

                            the compiler will do that for you and you can just call

                            TypeX->Something

                            and compiler have made sure its correct type you actually call on.

                            So its used in many cases to achieve good design.

                            T Offline
                            T Offline
                            tomy
                            wrote on 22 Nov 2017, 16:48 last edited by tomy
                            #13

                            @mrjj
                            Thanks mrjj, but unfortunately I couldn't understand that good concept.
                            Are you talking about virtual functions?

                            M 1 Reply Last reply 22 Nov 2017, 16:54
                            0
                            • T tomy
                              22 Nov 2017, 16:48

                              @mrjj
                              Thanks mrjj, but unfortunately I couldn't understand that good concept.
                              Are you talking about virtual functions?

                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 22 Nov 2017, 16:54 last edited by
                              #14

                              @tomy
                              Yes, virtual function are a way to archive polymorphism.

                              1 Reply Last reply
                              1

                              5/14

                              22 Nov 2017, 15:12

                              topic:navigator.unread, 9
                              • Login

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