Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:19:26+00:00 2026-05-31T15:19:26+00:00

I do not have much experience with C++ and I have a question regarding

  • 0

I do not have much experience with C++ and I have a question regarding the following lines from Qt documentation here : http://qt-project.org/doc/qt-4.8/mainwindows-application-mainwindow-h.html ( Lines 4-6 after the comment at the top )

 class QAction;
 class QMenu;
 class QPlainTextEdit;

Since QAction, QMenu and QPlainTextEdit are library classes of Qt ( clicking on them leads to their documentation pages), shouldn’t they be included using ‘#include ‘ ? What purpose does just declaring them with the keyword ‘class’ serve ? As far as I think , the compiler will think of it as a completely new class, having nothing to do with the library class QAction.

However, the ‘mainwindow.cpp’ file ( http://qt-project.org/doc/qt-4.8/mainwindows-application-mainwindow-cpp.html ) does not contain any definition of class QAction, though its objects are being used in the code.

What is going on here ?

Edit : Further explanation of the problem

Look into the createActions method of class MainWindow ( http://qt-project.org/doc/qt-4.8/mainwindows-application-mainwindow-cpp.html ). Here objects of class QAction are being created but nowhere can I find a definition of QAction class.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:19:28+00:00Added an answer on May 31, 2026 at 3:19 pm

    Those are known as “forward declarations” of the classes. It is used to make the compiler know that those symbols refer to classes, which are going to be defined afterwards. Those can be used in a header file to declare a symbol to be a class avoiding an inclusion of its header, which might be needed in some cases (circular inclusions for instance).

    You can’t always use forward declarations anyway, because the compiler might need to know how a class is defined. In other cases instead, the compiler needs only to know the fact that it actually is a class.

    EDIT: To answer the following question you added, have a look at the QtGui file you can find in *qt_install_dir*/include/QtGui. In my Qt 4.8 installation I see inside:

    #include "qaction.h"
    

    Then look inside qaction.h: you’ll see the complete definition of the QAction class. The inclusion of the header file QtGui is right at the beginning of your mainwindow.cpp, which makes QAction a complete type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 4 years experience on DotNet, not much. I now learned developing for
I'm not much into COM interfaces, so i have a small question, say I
I don't have much experience in SQL so I think this is not a
I don't have very much experience with MySQL so I am not sure what
I have not seen much support for Grails to develop facebook apps.I was just
I live in Australia and have not dealt much with imperial length measurements. How
I'm trying to define a new type and have not had much luck finding
I have not used generics much and so cannot figure out if it is
I have not used jquery much yet and not very familiar with it. Trying
I have not had to mess with mailto links much. However I now need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.