ISO C ++ Prohibits Declaring “QPushButton” Without Type in QT Creator

I am running QT Creator on Linux Ubuntu 9.10. I just started working with QT Creator, and I was going through tutorials when this error occurred when I tried to create my project: "ISO C ++ prohibits declaring" QPushButton "without type". This problem appears in my header file:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QtGui/QWidget>

namespace Ui
{
    class MainWindow;
}

class MainWindow : public QWidget
{
    Q_OBJECT

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

public slots:
    void addContact();
    void submitContact();
    void cancel();

private:
    Ui::MainWindow *ui;
    QPushButton *addButton;
    QPushButton *submitButton;
    QPushButton *cancelButton;
    QLineEdit *nameLine;
    QTextEdit *addressText;

    QMap<QString, QString> contacts;
    QString oldName;
    QString oldAddress;


};
#endif // MAINWINDOW_H
+3
source share
4 answers

I think the corresponding header file is simply missing. Can you try

#include <QtGui/QtGui> 

instead, or if you prefer

#include <QtGui/QPushButton>
+7
source

In fact, forwarding declarations will be enough, instead of include:

class QPushButton;

.cpp( ).

+5

:

#include <QtGui>
+1

You can also check the .pro file.
Do you have an entry like "QT = ..."? If so, try changing this to "QT + = ...". The Qt Core and GUI module are the default settings for the QT variable, but can be overwritten, resulting in compiler and / or linker errors.

0
source

Source: https://habr.com/ru/post/1742586/


All Articles