Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Clarification required in MainWindow Example

    General and Desktop
    2
    3
    1343
    Loading More Posts
    • 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
      aakashbhowmick last edited by

      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 Reply Quote 0
      • K
        koahnig last edited by

        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 Reply Quote 0
        • K
          koahnig last edited by

          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 Reply Quote 0
          • First post
            Last post