Explaining code
-
I KNOW I AM NOT SUPPOSED TO ASK PROGRAMMING QUESTIONS HERE
BUT
since most of the participants in this (purely) academic discussion (IMHO) are usually the one who actually answer my post
I am just being selfish and post here.As usual , I like to get plain English description of the following
pointer usage :QList<QMdiSubWindow *> windows = mdiArea->subWindowList(); ??
QMdiSubWindow *mdiSubWindow = windows.at(i); note: this is the one " I get" !
MdiChild *child = qobject_cast<MdiChild *>(mdiSubWindow->widget()); ??
and just for good measure - here is my measly contribution to the lounge talk
header files are pain - I have been thru hell keeping track of .pro and .h "includes".
I vote to get rid of headers -JUST KIDDINGthe second reason to remove headers - until somebody comes up with
a way to memorize what is
definition and what is a declaration.....Qt have no chance in hell to adopt any other language because
IT IS A LIBRARY ( not language ) - been told many times ...As long as any new language BOOK will NOT exceed
" K&R C programming language" book size and # of PAGES
AKAKISS
[Chris Kawa]: Post moved. Don't hijack other threads.
-
@AnneRanch said in Explaining code:
header files are pain - I have been thru hell keeping track of .pro and .h "includes".
I vote to get rid of headers -JUST KIDDINGSo you want to tell us that if someone is unable to look into the documentation to see what header to include for what class the one is able to look up into the documentation to look up what module to import to use a specific class?
the second reason to remove headers - until somebody comes up with
a way to memorize what is
definition and what is a declaration.....This will not help at all - if you don't declare a class you can't define the implementation later on - this has nothing to do if you do it in a header or somewhere else.
-
@AnneRanch said:
As usual , I like to get plain English description of the following pointer usage
// QMdiArea is a container of subwindows // Get a list of pointers to those subwindows and assign it to a local list variable named "windows" QList<QMdiSubWindow *> windows = mdiArea->subWindowList(); // Assign i-th element of that list to a local variable "mdiSubWindow" QMdiSubWindow *mdiSubWindow = windows.at(i); // QMdiSubWindow is a container that hosts a widget. // Retrieve a pointer to that widget // Try to cast that pointer to a pointer to type MdiChild and assign the result to local variable "child" // If the cast succeeds then the variable "child" points to the widget hosted by QMdiSubWindow // If the cast fails (widget is not a MdiChild class) then the variable "child" is a nullptr MdiChild *child = qobject_cast<MdiChild *>(mdiSubWindow->widget());
somebody comes up with a way to memorize what is definition and what is a declaration
You can try to remember it by imagining a herald on a town square. He's declaring, or in other words announcing that something exists e.g. "Hello good people. The function x exists! Let's be happy!".
Then someone from the crowd asks "ok, but what is it?" and a local scientist defines it, or in other words explains/describes it in detail, saying that "x is this and that my friends and it does this in that way".
Herald is your header declaration guy.
Scientist is your cpp definition guy.