QT error multiple declarations?

This is a discussion on QT error multiple declarations? within the Linux Programming forums, part of the Platform Specific Boards category; Im trying to create a fail safe integer input in QT but am getting some errors. If my code is ...

  1. #1
    Registered User
    Join Date
    Jul 2003

    QT error multiple declarations?

    Im trying to create a fail safe integer input in QT but am getting some errors.
    If my code is way off the ball park let me know with your coments
    #include <qwidget.h>
    #include <qlineedit.h>
    class QTIntegerInput : public QWidget
        QTIntegerInput(QWidget * parent);
        int valid_integer;
        QLineEdit *number_box;
        void handle_overflow(const QString & unvalidated_integer);
       private slots:
        void overflow();
        int get_integer(); 
    next the implementation
    #include <iostream>
    using std::cerr;
    #include <qlayout.h>
    #include <qlabel.h>
    #include <qvalidator.h>
    #include <qwidget.h>
    #include "QTIntegerInput.h"
    QTIntegerInput::QTIntegerInput(QWidget * parent) : QWidget(parent)
      QHBoxLayout *input_layout_box = new QHBoxLayout(this);
      QLabel *label = new QLabel(tr("Please &enter an integer:"),this);
      number_box = new QLineEdit(this);
      QRegExp isDigit("[0-9]{16}");
      number_box->setValidator(new QRegExpValidator(isDigit,number_box));
      QObject::connect(number_box, SIGNAL(returnPressed()),this, SLOT(overflow()));
    void QTIntegerInput::overflow()
          bool ok;
          int unvalidated_integer = number_box->text().toInt( &ok, 10 );     // dec == 0, ok == FALS
          if (ok==FALSE) throw "overflow exception";
          valid_integer = unvalidated_integer;
        catch (char * exception)
          emit handle_overflow(number_box->text());
    void QTIntegerInput::handle_overflow(const QString &unvalidated){ cerr << "Overflow";}
    int QTIntegerInput::get_integer(){return 0;}
    moc_QTIntegerInput.o(.text+0x1ec): In function `QTIntegerInput::handle_overflow(QString const&)':
    /home/curlious/qtenternumber/src/moc_QTIntegerInput.cpp:87: multiple definition of `QTIntegerInput::handle_overflow(QString const&)'
    QTIntegerInput.o(.text+0x0):/usr/lib64/qt-3.3/include/qglist.h:150: first defined here
    /usr/bin/ld: Warning: size of symbol `QTIntegerInput::handle_overflow(QString const&)' changed from 15 in QTIntegerInput.o to 112 in moc_QTIntegerInput.o
    collect2: ld returned 1 exit status
    gmake[1]: *** [../bin/qtenternumber] Error 1
    gmake: *** [sub-src] Error 2
    *** Exited with status: 2 ***

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Try changing the name, because the library seems to already use it.
    /usr/lib64/qt-3.3/include/qglist.h:150: first defined here
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jul 2003
    I looked at that header file and it seems totally unrelated.

    I found the problem. You do not define a routine for a signal. I changed my signal to throw_overflow then created a slot handle_overflow for which there is an exception.

    You may wonder why I just didn't handle this in the catch clause of overflow. I am thinking that I will add a dialog and this would be to much in a simple catch clause.

    Thanks Salem for getting me to look at this deeper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Does gcc hate Forward declarations?
    By SevenThunders in forum C++ Programming
    Replies: 12
    Last Post: 03-16-2009, 03:03 PM
  2. QT 4 and MSVC 6.0. Need help/
    By LMZ in forum C++ Programming
    Replies: 1
    Last Post: 09-15-2006, 04:57 PM
  3. QT or others for the beginning linux programmer
    By FillYourBrain in forum Linux Programming
    Replies: 3
    Last Post: 09-12-2003, 02:17 PM
  4. First QT App
    By Troll_King in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 07-26-2002, 10:30 AM
  5. EASY GUI development.. like with Qt?
    By rezonax in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2001, 02:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21