BUG. Qt 5.0.2, Windows 32-bit, MinGW 4.7

  • This example code from Max Schlee's Qt-book not comliling.

    @/* ======================================================================
    ** main.cpp
    ** ======================================================================
    ** ======================================================================
    ** Copyright (c) 2007 by Max Schlee
    ** ======================================================================

    #include <QtGui>
    #include "Counter.h"

    // ----------------------------------------------------------------------
    int main (int argc, char** argv)
    QApplication app(argc, argv);

    QLabel      lbl("0");
    QPushButton cmd&#40;"ADD"&#41;;
    Counter     counter;
    QObject::connect(&cmd, SIGNAL(clicked()), 
                     &counter, SLOT(slotInc())
    QObject::connect(&counter, SIGNAL(counterChanged(int)),
                     &lbl, SLOT(setNum(int))
    QObject::connect(&counter, SIGNAL(goodbye()), 
                     &app, SLOT(quit())
    return app.exec&#40;&#41;;


    IDE says:
    @main.cpp:-1: In function 'int qMain(int, char**)':
    main.cpp:16: error: variable 'QApplication app' has initializer but incomplete type
    main.cpp:18: error: 'QLabel' was not declared in this scope
    main.cpp:18: error: expected ';' before 'lbl'
    main.cpp:19: error: 'QPushButton' was not declared in this scope
    main.cpp:19: error: expected ';' before 'cmd'
    main.cpp:22: error: 'lbl' was not declared in this scope
    main.cpp:23: error: 'cmd' was not declared in this scope
    main.cpp:38: warning: control reaches end of non-void function [-Wreturn-type]

    I had same-like problem with "Hello World" project. At that time the problem was solved by replacing
    @#include <QtGui>@

    @#include <QApplication>
    #include <QLabel>@

    But now it did not help. I tried to recompile "Hello World" project with "#include <QtGui>" and it is going. What's the problem? Random bug?

    -- UPD --

    OS Windows 7 Pro SP1, x64.
    Qt build: "Qt 5.0.2, Windows 32-bit, MinGW 4.7":http://download.qt-project.org/official_releases/qt/5.0/5.0.2/qt-windows-opensource-5.0.2-mingw47_32-x86-offline.exe
    Qt build installation settings: default.

  • Not a bug... Just add QT += widgets to your PRO file and #include <QtWidgets> instead of QtGui

  • Ignore this.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.