Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. No definition of QLabel class in my Qt 5.1[SOLVED]???

No definition of QLabel class in my Qt 5.1[SOLVED]???

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.2k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    rsjethani
    wrote on last edited by
    #1

    Hi,

    I am learning Qt through Qt 5.1 32 bit on Linux Mint 15 32 bit. Default install path: ~/Qt5.1.0/... I created a very simple program in Qt creator:

    @#include<QtWidgets>

    int main(int argc, char *argv[])
    {
    QApplication app(argc,argv);
    QLabel l;
    l.show();
    return app.exec();

    }@

    I get the following output:

    @01:32:24: Running steps for project untitled...
    01:32:24: Configuration unchanged, skipping qmake step.
    01:32:24: Starting: "/usr/bin/make"
    g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../Qt5.1.0/5.1.0/gcc/mkspecs/linux-g++ -I. -I../../../Qt5.1.0/5.1.0/gcc/include -I../../../Qt5.1.0/5.1.0/gcc/include/QtWidgets -I../../../Qt5.1.0/5.1.0/gcc/include/QtGui -I../../../Qt5.1.0/5.1.0/gcc/include/QtCore -I. -o main.o main.cpp
    In file included from ../../../Qt5.1.0/5.1.0/gcc/include/QtWidgets/QtWidgets:98:0,
    from main.cpp:1:
    ../../../Qt5.1.0/5.1.0/gcc/include/QtWidgets/qlabel.h:52:24: error: redefinition of 'class QPushButton'
    In file included from ../../../Qt5.1.0/5.1.0/gcc/include/QtWidgets/qcommandlinkbutton.h:45:0,
    from ../../../Qt5.1.0/5.1.0/gcc/include/QtWidgets/QtWidgets:89,
    from main.cpp:1:
    ../../../Qt5.1.0/5.1.0/gcc/include/QtWidgets/qpushbutton.h:54:24: error: previous definition of 'class QPushButton'
    main.cpp: In function 'int main(int, char**)':
    main.cpp:6:13: error: aggregate 'QLabel l' has incomplete type and cannot be defined
    make: *** [main.o] Error 1
    01:32:26: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project untitled (kit: Desktop Qt 5.1.0 GCC 32bit)
    When executing step 'Make'
    01:32:26: Elapsed time: 00:02.@

    And here is the .pro file:
    @#-------------------------------------------------

    Project created by QtCreator 2013-12-30T15:26:07

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = untitled
    TEMPLATE = app

    SOURCES += main.cpp

    HEADERS +=
    @

    To investigate what is going wrong I sniffed around into the Qt5.1.0/gcc/include/QtWidgets/ directory
    only to discover that there is no definition of class QLabel in qlabel.h..what the heck...and on top of it qlabel.h contains definition of QPushButton??? which is also defined in qpushbutton.h and this I guess is causing the QPushButton redefinition error. I did a simple grep search on the include directory:
    @ryan@mint15 ~/Qt5.1.0/5.1.0/gcc/include $ find -type f -exec grep QLabel '{}' +
    ./QtQuick/5.1.0/QtQuick/private/qquicktextcontrol_p.h:// also used by QLabel
    ./QtDesigner/5.1.0/QtDesigner/private/formbuilderextra_p.h:class QLabel;
    ./QtDesigner/5.1.0/QtDesigner/private/formbuilderextra_p.h: static bool applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel label);
    ./QtDesigner/5.1.0/QtDesigner/private/formbuilderextra_p.h: typedef QHash<QLabel
    , QString> BuddyHash;
    ./QtDesigner/5.1.0/QtDesigner/private/qdesigner_widget_p.h:#include <QtWidgets/QLabel>
    ./QtDesigner/5.1.0/QtDesigner/private/stylesheeteditor_p.h:#include <QtWidgets/QLabel>
    ./QtDesigner/5.1.0/QtDesigner/private/stylesheeteditor_p.h: QLabel *m_validityLabel;
    ./QtWidgets/5.1.0/QtWidgets/private/qwidgettextcontrol_p.h:// also used by QLabel
    ./QtWidgets/5.1.0/QtWidgets/private/qlabel_p.h:class QLabelPrivate : public QFramePrivate
    ./QtWidgets/5.1.0/QtWidgets/private/qlabel_p.h: Q_DECLARE_PUBLIC(QLabel)
    ./QtWidgets/5.1.0/QtWidgets/private/qlabel_p.h: QLabelPrivate() {}
    ./QtWidgets/5.1.0/QtWidgets/private/qheaderview_p.h: QLabel *sectionIndicator;
    ./QtWidgets/5.1.0/QtWidgets/private/qcolordialog_p.h:class QLabel;
    ./QtWidgets/5.1.0/QtWidgets/private/qcolordialog_p.h: QLabel *lblBasicColors;
    ./QtWidgets/5.1.0/QtWidgets/private/qcolordialog_p.h: QLabel *lblCustomColors;
    ./QtWidgets/5.1.0/QtWidgets/private/qcalendartextnavigator_p.h:class QLabel;
    ./QtWidgets/5.1.0/QtWidgets/private/qcalendartextnavigator_p.h: QLabel *m_dateText;
    ./QtWidgets/5.1.0/QtWidgets/private/qsystemtrayicon_p.h:class QLabel;
    ./QtWidgets/5.1.0/QtWidgets/private/qfontdialog_p.h:class QLabel;
    ./QtWidgets/5.1.0/QtWidgets/private/qfontdialog_p.h: QLabel *familyAccel;
    ./QtWidgets/5.1.0/QtWidgets/private/qfontdialog_p.h: QLabel *styleAccel;
    ./QtWidgets/5.1.0/QtWidgets/private/qfontdialog_p.h: QLabel *sizeAccel;
    ./QtWidgets/5.1.0/QtWidgets/private/qfontdialog_p.h: QLabel *writingSystemAccel;
    ./QtWidgets/qprogressdialog.h:class QLabel;
    ./QtWidgets/qprogressdialog.h: void setLabel(QLabel *label);
    ./QtWidgets/qmessagebox.h:class QLabel;
    ./QtWidgets/qlabel.h:class QLabelPrivate;
    ./QtWidgets/qlabel.h: Q_DISABLE_COPY(QLabel)
    ./QtWidgets/qlabel.h: Q_DECLARE_PRIVATE(QLabel)
    ./QtCore/qnamespace.h: // Text formatting flags for QPainter::drawText and QLabel.
    @

    Result....no definition of a class calle QLabel anywhere. As you can see only forward declarations of a class QLabel and some class called QLabelPrivate. Where the hell is QLabel? How can I mess up such a simple program OR is there something wrong with Qt5.1 ??
    Thanks.

    EDIT:: I reinstalled Qt 5.1 and now the qlabel.h file contains what it should. All errors are gone. I don't know what happened earlier huh!!!

    Ravi S. Jethani

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      [quote author="Ravi S. Jethani" date="1388607785"]
      To investigate what is going wrong I sniffed around into the Qt5.1.0/gcc/include/QtWidgets/ directory only to discover that there is no definition of class QLabel in qlabel.h.
      [/quote]
      That's not where QLabel is actually defined and implemented. The directory for the QWidgets is:
      <QTDIR>\qtbase\src\widgets\widgets

      Did you compile Qt yourself or downloaded a precompiled version?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rsjethani
        wrote on last edited by
        #3

        [quote author="raven-worx" date="1388647896"]
        Did you compile Qt yourself or downloaded a precompiled version?
        [/quote]

        I installed the binary version(the .run file) from Qt download page few months back when Qt5.1 was released.

        Ravi S. Jethani

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved