Results 1 to 1 of 1

Thread: MyLineEdit + signals lead to multiple definition [solved]

  1. #1
    Join Date
    Sep 2014
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default MyLineEdit + signals lead to multiple definition [solved]

    Great, no I fucked my posting up...

    I try to rewrite it again. All I wanted was a LineEdit that emits signals if e.g. Qt::Key_Up was pressed. Therefore I subclassed QLineEdit as the following code shows.

    Qt Code:
    1. #ifndef MYLINEEDIT_H
    2. #define MYLINEEDIT_H
    3.  
    4. #include <QLineEdit>
    5. #include <QKeyEvent>
    6.  
    7. class MyLineEdit : public QLineEdit
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. MyLineEdit();
    13.  
    14. signals:
    15. void MyKeyUpPressed();
    16.  
    17. protected:
    18. void keyPressEvent(QKeyEvent *event);
    19. };
    20.  
    21. #endif // MYLINEEDIT_H
    To copy to clipboard, switch view to plain text mode 

    First I only had qDebug() within keyPressEvent() and everything compiled Then I added MyKeyUpPressed() as a signal, as it's shown in the code.

    Qt Code:
    1. #include "mylineedit.h"
    2. #include <QDebug>
    3.  
    4. MyLineEdit::MyLineEdit()
    5. {
    6. }
    7.  
    8. void MyLineEdit::MyKeyUpPressed()
    9. {
    10. qDebug() << "Key up";
    11. }
    12.  
    13. void MyLineEdit::keyPressEvent(QKeyEvent *event)
    14. {
    15. switch (event->key())
    16. {
    17. case Qt::Key_Up:
    18. emit MyLineEdit::MyKeyUpPressed();
    19. // qDebug() << "Key Up";
    20. break;
    21. default:
    22. QLineEdit::keyPressEvent(event);
    23. break;
    24. }
    25. }
    To copy to clipboard, switch view to plain text mode 

    At that point I got compiling errors...

    (..)\debug\moc_mylineedit.cpp:121: Fehler: multiple definition of `MyLineEdit::MyKeyUpPressed()'

    Any Suggestions?

    ----------------------------------------------------------------

    What an easy, dumb failure.....There is no need to fill signals with life (code).

    Qt Code:
    1. //void MyLineEdit::MyKeyUpPressed()
    2. //{
    3. //qDebug() << "Key up";
    4. //}
    To copy to clipboard, switch view to plain text mode 
    Last edited by schotter; 4th February 2015 at 13:32. Reason: reformatted to look better

Similar Threads

  1. Replies: 1
    Last Post: 26th September 2012, 10:09
  2. Non-existing multiple definition bug
    By uGin in forum Qt Programming
    Replies: 1
    Last Post: 17th May 2011, 17:53
  3. Replies: 1
    Last Post: 17th May 2011, 17:12
  4. qmake - multiple definition ?
    By zaphod77 in forum Installation and Deployment
    Replies: 3
    Last Post: 6th April 2011, 13:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.