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. Clarification required in MainWindow Example
QtWS25 Last Chance

Clarification required in MainWindow Example

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.5k 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.
  • A Offline
    A Offline
    aakashbhowmick
    wrote on last edited by
    #1

    With reference to the MainWindow example here : http://qt-project.org/doc/qt-4.8/examples-mainwindow.html

    If you look into the mainwindow.h file ( http://qt-project.org/doc/qt-4.8/mainwindows-application-mainwindow-h.html ) , at the top class QAction has been defined , but nowhere could I find any definition of the class.

    However, in the mainwindow.cpp file ( http://qt-project.org/doc/qt-4.8/mainwindows-application-mainwindow-cpp.html ) in the createActions method of MainWindow class, an object of QAction is being created by calling its constructor. Howver, I could not find any definition of the constructor.

    Since QActios is a library class, shouldn't it be included in the code using '#include' ? Where has QAction class been defined ? What's going on here ?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      welcome to devnet

      The class statement in this example QAction tells the compiler that QAction is a class. You need this that the compiler knows what to do with the QAction pointer definitions. It does not need more infos at this point.

      There is an include for QtGui in the mainwindows. This include basically summarizes a number of other includes (QAction is part of them).
      Within the .cpp file the compiler finally needs to know how to handle QAction. This is the latest point to define QAction which is done through the QtGui include.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        Here is a link for "some explanation on this (see second code window)":http://www.flipcode.com/archives/Reducing_Dependencies_In_C.shtml

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0

        • Login

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