Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. The Lounge
  4. Explaining code
Forum Updated to NodeBB v4.3 + New Features

Explaining code

Scheduled Pinned Locked Moved Unsolved The Lounge
3 Posts 3 Posters 636 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 10 Dec 2022, 02:22 last edited by Chris Kawa 12 Oct 2022, 15:26
    #1

    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 KIDDING

    the 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
    AKA

    KISS

    [Chris Kawa]: Post moved. Don't hijack other threads.

    C 1 Reply Last reply 10 Dec 2022, 17:43
    0
    • A Anonymous_Banned275
      10 Dec 2022, 02:22

      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 KIDDING

      the 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
      AKA

      KISS

      [Chris Kawa]: Post moved. Don't hijack other threads.

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 10 Dec 2022, 17:43 last edited by
      #2

      @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 KIDDING

      So 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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on 10 Dec 2022, 17:55 last edited by Chris Kawa 12 Oct 2022, 18:39
        #3

        @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.

        1 Reply Last reply
        2

        1/3

        10 Dec 2022, 02:22

        • Login

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