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

  • SEARCH
  • Home
  • 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 6886441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:45:35+00:00 2026-05-27T05:45:35+00:00

Not sure this issue about Qt or C++ in general, I’m just a newbie

  • 0

Not sure this issue about Qt or C++ in general, I’m just a newbie for both of these!
I got a simple Qt app, with a MainWindow and Hello class like below:

hello.h

#ifndef HELLO_H
#define HELLO_H

#include <QWidget>
#include "mainwindow.h"

class Hello : public QWidget
{
    Q_OBJECT
public:
    explicit Hello(MainWindow *parent = 0);

signals:

public slots:

};

#endif // HELLO_H

heloo.cpp

#include "hello.h"

Hello::Hello(MainWindow *parent) :
    QWidget(parent)
{
//nothing here yet
}

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QMainWindow>
#include "hello.h"

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Hello* hi;
};

#endif // MAINWINDOW_H

mainwindows.cpp

#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    hi = new Hello(this);
}

MainWindow::~MainWindow()
{

}

main.cpp

#include <QtGui/QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

and here is the error when I build my project:

from ../untitled1/main.cpp:2: ../untitled1/hello.h:11: error: expected
‘)’ before ‘*’ token

and the line cause the error is:

explicit Hello(MainWindow *parent = 0);

Can you help me to resolve the issue!
Thanks you!

  • 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-27T05:45:35+00:00Added an answer on May 27, 2026 at 5:45 am

    You have circular inclusion of header files in “hello.h” and “maindwindow.h”. There is no need to include these files in the header file as you are just using a pointer. A simple forward declaration such as class MainWindow; in “hello.h” is sufficient.

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

Sidebar

Related Questions

I'm having the craziest issue with Firefox. I'm not sure if this issue is
Not sure this is a known issue. I’m using VS2012 RC (Ultimate), and Win8
I'm not sure if this is a flask specific issue or if I simply
I'm not sure if this is a simulator issue, but I don't remeber having
I'm not quite sure how to approach this issue: I am creating a web
Disclaimer: not sure this is WordPress related or not. I'm following a simple tutorial
I'm sure this is a simple issue, but I have noticed that when I
Not sure this is possible, but looking to write a script that would return
I'm not sure this is the right forum if it's not please feel free
I'm not sure this is even possible but I know if it is, the

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.