Results 1 to 20 of 26

Thread: Function previously defined in created file?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Function previously defined in created file?

    Quote Originally Posted by Twey
    Yes. Is this not correct?
    No it's perfectly legitimate that's not the problem, I was just thinking of various things for what happens, but I still can't visualize it. When I said that you should be more descriptive I meant for the workaround you found that didn't fit your needs. If it's possible attach your sourcecode to duplicate the error.
    Quote Originally Posted by Twey
    There really ought to be scrollbars on those [Q U O T E] boxes.
    You can use the [C O D E] (without the spaces of cource) tag instead to get scrollbars

  2. #2
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Function previously defined in created file?

    The workaround was to keep the implementation out of both SOURCES and HEADERS groups.
    Source attached.
    Attached Files Attached Files

  3. #3
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Function previously defined in created file?

    From the assistant (Signals and Slots)
    Signals are automatically generated by the moc and must not be implemented in the .cpp file.
    Remove the implementation of your mouseMoved() and you' re done

    Edit: Also rename this slot void QDoubleButton::clicked(). It's got the same name as the signal
    Last edited by yop; 14th January 2006 at 17:02.

  4. #4
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Function previously defined in created file?

    Aha I did find the first problem, shortly after posting, but not the second.
    Nevertheless, I still get these:
    Qt Code:
    1. moc_qdoublebutton.o(.text+0x0): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    2. /usr/lib/qt-3.3/include/qglist.h:150: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    3. app4lin.o(.text+0x0):/usr/lib/qt-3.3/include/qglist.h:150: first defined here
    4. moc_qdoublebutton.o(.text+0x3a): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    5. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.h:17: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    6. app4lin.o(.text+0x3a):/home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.h:17: first defined here
    7. moc_qdoublebutton.o(.text+0x74): In function `QTrackingButton::mouseMoveEvent(QMouseEvent*)':
    8. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.h:21: multiple definition of `QTrackingButton::mouseMoveEvent(QMouseEvent*)'
    9. app4lin.o(.text+0x74):/home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.h:21: first defined here
    10. moc_qdoublebutton.o(.text+0x304): In function `QDoubleButton::clicked()':
    11. /home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.h:31: multiple definition of `QDoubleButton::clicked()'
    12. app4lin.o(.text+0x4ee):/home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.h:31: first defined here
    13. moc_qdoublebutton.o(.text+0x3fa): In function `QDoubleButton::moused()':
    14. /home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.h:36: multiple definition of `QDoubleButton::moused()'
    15. app4lin.o(.text+0x5e4):/home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.h:36: first defined here
    16. moc_qdoublebutton.o(.text+0x556): In function `QDoubleButton::QDoubleButton(QWidget*, char*)':
    17. /home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.h:18: multiple definition of `QDoubleButton::QDoubleButton(QWidget*, char*)'
    18. app4lin.o(.text+0x7e):/home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.h:18: first defined here
    19. /usr/bin/ld: Warning: size of symbol `QDoubleButton::QDoubleButton(QWidget*, char*)' changed from 488 in app4lin.o to 484 in moc_qdoublebutton.o
    20. moc_qdoublebutton.o(.text+0x73a): In function `QDoubleButton::QDoubleButton(QWidget*, char*)':
    21. /home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.h:18: multiple definition of `QDoubleButton::QDoubleButton(QWidget*, char*)'
    22. app4lin.o(.text+0x266):/home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.h:18: first defined here
    23. /usr/bin/ld: Warning: size of symbol `QDoubleButton::QDoubleButton(QWidget*, char*)' changed from 484 in app4lin.o to 488 in moc_qdoublebutton.o
    24. moc_qtrackingbutton.o(.text+0x364): In function `QTrackingButton::mouseMoveEvent(QMouseEvent*)':
    25. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.h:21: multiple definition of `QTrackingButton::mouseMoveEvent(QMouseEvent*)'
    26. app4lin.o(.text+0x74):/home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.h:21: first defined here
    27. moc_qtrackingbutton.o(.text+0x0): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    28. moc_qtrackingbutton.cpp: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    29. app4lin.o(.text+0x0):app4lin.cxx: first defined here
    30. moc_qtrackingbutton.o(.text+0x3a): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    31. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.h:17: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    32. app4lin.o(.text+0x3a):/home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.h:17: first defined here
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Function previously defined in created file?

    Looks like missing include guards, i.e.

    Qt Code:
    1. #ifndef SOMEHEADER_H
    2. #define SOMEHEADER_H
    3.  
    4. class SomeClass
    5. {
    6. };
    7.  
    8. #endif
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  6. #6
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Function previously defined in created file?

    Nope, got them.

  7. #7
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Function previously defined in created file?

    The attached project built fine with:
    g++ --version
    g++ (GCC) 3.3.5 20050117 (prerelease) (SUSE Linux)
    qmake --version
    Qmake version: 1.07a (Qt 3.3.4)
    under Suse Linux 9.3
    A diff with your files will be usefull
    Attached Files Attached Files

  8. #8
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Function previously defined in created file?

    Yes, builds here too. diff attached.

    /EDIT: Of more interest might be this diff between your project and the same project when declaration and implementation are cat'ed into one file, which gives the same errors as above.
    Attached Files Attached Files
    Last edited by Twey; 14th January 2006 at 19:27. Reason: Well, I thought the diff was attached...

  9. #9
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Function previously defined in created file?

    Apparently that was the problem

  10. #10
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Function previously defined in created file?

    Quote Originally Posted by yop
    Quote Originally Posted by Myself
    Is this [putting definition and implementation in the same file] not correct?
    No it's perfectly legitimate that's not the problem
    If that's so, I don't understand why it should be a problem :-\

  11. #11
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Function previously defined in created file?

    Yes it's food for thought, I've been googling around for it but I can't seem to find any answers . It was a trial and error process for me too. It really felt right to have it in the header file (I would have told you to remove them in the first place) but apparenty it's not.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Function previously defined in created file?

    Quote Originally Posted by Twey
    If that's so, I don't understand why it should be a problem :-\
    In such case you must add a hint for qmake that it should run moc program on your .cpp file, as it only checks headers for Q_OBJECT.

    You have to add:
    Qt Code:
    1. #include "filename.moc"
    To copy to clipboard, switch view to plain text mode 
    at the end of a file.

    Edit: OK, forget it. I should check your program before posting. The problem is different.
    Last edited by jacek; 14th January 2006 at 20:23.

  13. #13
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Function previously defined in created file?

    Quote Originally Posted by jacek
    In such case you must add a hint for qmake that it should run moc program on your .cpp file, as it only checks headers for Q_OBJECT.
    But the files were headers.
    Also, yop, when the second button in your code (b2) is connected to the moused() slot, nothing happens.

  14. #14
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Function previously defined in created file?

    Quote Originally Posted by jacek
    In such case you must add a hint for qmake that it should run moc program on your .cpp file, as it only checks headers for Q_OBJECT.

    You have to add:
    Qt Code:
    1. #include "filename.moc"
    To copy to clipboard, switch view to plain text mode 
    at the end of a file.
    Don't you get a vtable blah blah error in that case? There is an undefined reference error here. Ok I'll shut up and reboot linux to check it out myself...

    Quote Originally Posted by jacek
    Edit: OK, forget it. I should check your program before posting. The problem is different.
    Edit: Ok no need to check it out then
    Last edited by yop; 14th January 2006 at 20:29.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Regading Driver to connect Postgresql Database
    By dummystories in forum Installation and Deployment
    Replies: 38
    Last Post: 12th March 2009, 07:19
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.