Unsolved A double buffering project
-
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)and then after getting the default project ( right click top of project )
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" -
@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
-
@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?
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.
-
@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 -
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) -
-
@tomy
But they are ?!
-
@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! -
@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/ -
@mrjj
OK, thanks. -
@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 toif ( 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.
-
@mrjj
Thanks mrjj, but unfortunately I couldn't understand that good concept.
Are you talking about virtual functions? -
@tomy
Yes, virtual function are a way to archive polymorphism.