Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: Function previously defined in created file?

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

    Default Function previously defined in created file?

    When I do qmake -project;qmake;make on a project containing files with the Q_OBJECT macro, I get something like this:
    moc_qtrackingbutton.cpp:80: error: redefinition of ‘void QTrackingButton::mouseMoved()’
    qtrackingbutton.h:23: error: ‘void QTrackingButton::mouseMoved()’ previously defined here
    make: *** [moc_qtrackingbutton.o] Error 1
    I've searched the internet a bit, and apparently putting the member functions in a different file to the class definition works. I did this, but it gave me "undefined reference to `vtable for classname'", until I moved these files out of the directory, then did qmake -project;qmake, then moved them back in for the final make. This is neither elegant nor convenient. Is there any way around, other than that?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Function previously defined in created file?

    First of all qmake -project should only be done once when you start working on a project. It creates a template for the project file, which then should be updated manualy. The error you experience is probably because you run qmake -project on a directory which already contains files generated by moc and these file are added to the SOURCES group but they shouldn't. So either make distclean before running qmake -project again or modify the project file yourself (which is the way to go).

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

    Default Re: Function previously defined in created file?

    Behold: no moc-generated files of any kind.
    ($:app4lin) ls -a
    ./ ../ app4lin.cxx qdoublebutton.h qtrackingbutton.h
    Now, after qmake -project:
    ($:app4lin) ls -a
    ./ ../ app4lin.cxx app4lin.pro qdoublebutton.h qtrackingbutton.h
    All as expected. qmake and:
    ($:app4lin) ls -a
    ./ ../ app4lin.cxx app4lin.pro Makefile qdoublebutton.h qtrackingbutton.h
    Again, all good. Then a make:
    ($:app4lin) make
    g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o app4lin.o app4lin.cxx
    ./qtrackingbutton.h:18: warning: unused parameter ‘e’
    /usr/lib/qt-3.3/bin/moc qdoublebutton.h -o moc_qdoublebutton.cpp
    g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o moc_qdoublebutton.o moc_qdoublebutton.cpp
    qtrackingbutton.h:18: warning: unused parameter ‘e’
    /usr/lib/qt-3.3/bin/moc qtrackingbutton.h -o moc_qtrackingbutton.cpp
    g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o moc_qtrackingbutton.o moc_qtrackingbutton.cpp
    qtrackingbutton.h:18: warning: unused parameter ‘e’
    moc_qtrackingbutton.cpp:80: error: redefinition of ‘void QTrackingButton::mouseMoved()’
    qtrackingbutton.h:23: error: ‘void QTrackingButton::mouseMoved()’ previously defined here
    make: *** [moc_qtrackingbutton.o] Error 1
    My .pro file:
    ################################################## ####################
    # Automatically generated by qmake (1.07a) Sat Jan 14 11:45:09 2006
    ################################################## ####################

    TEMPLATE = app
    INCLUDEPATH += .

    # Input
    HEADERS += qdoublebutton.h qtrackingbutton.h
    SOURCES += app4lin.cxx
    Nothing in SOURCES that shouldn't be.
    Last edited by Twey; 14th January 2006 at 11:53.

  4. #4
    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
    ...apparently putting the member functions in a different file to the class definition works. I did this, but it gave me "undefined reference to `vtable for classname'", until I moved these files out of the directory, then did qmake -project;qmake, then moved them back in for the final make. This is neither elegant nor convenient. Is there any way around, other than that?
    Could you please be a little more descriptive. It should be easy to deal with this kind of error, but I really haven't totally undertood the problem.

    Edit: As I can guess from the .pro file, you have implementation and declaration in the header file?
    Edit2:Sorry I apparently pressed the forward button insted of edit while reading my previous post and I can't seem to find a way to delete the duplicate
    Last edited by yop; 14th January 2006 at 12:10.

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

    Default Re: Function previously defined in created file?

    As I can guess from the .pro file, you have implementation and declaration in the header file?
    Yes. Is this not correct? Here, I have cleaned all make- and qmake-generated files, moved my implementation to seperate .cxx files, and tried to build again.
    Qt Code:
    1. ($:app4lin) make
    2. g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o app4lin.o app4lin.cxx
    3. ./qtrackingbutton.cxx:20: warning: unused parameter ‘e’
    4. g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o qdoublebutton.o qdoublebutton.cxx
    5. qtrackingbutton.cxx:20: warning: unused parameter ‘e’
    6. g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o qtrackingbutton.o qtrackingbutton.cxx
    7. qtrackingbutton.cxx:20: warning: unused parameter ‘e’
    8. /usr/lib/qt-3.3/bin/moc qdoublebutton.h -o moc_qdoublebutton.cpp
    9. g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o moc_qdoublebutton.o moc_qdoublebutton.cpp
    10. qtrackingbutton.cxx:20: warning: unused parameter ‘e’
    11. /usr/lib/qt-3.3/bin/moc qtrackingbutton.h -o moc_qtrackingbutton.cpp
    12. g++ -c -pipe -Wall -W -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -DQT_NO_DEBUG -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -I/usr/lib/qt-3.3/include -o moc_qtrackingbutton.o moc_qtrackingbutton.cpp
    13. g++ -Wl,-rpath,/usr/lib/qt-3.3/lib -o app4lin app4lin.o qdoublebutton.o qtrackingbutton.o moc_qdoublebutton.o moc_qtrackingbutton.o -L/usr/lib/qt-3.3/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
    14. qdoublebutton.o(.text+0x0): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    15. /usr/lib/qt-3.3/include/qglist.h:150: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    16. app4lin.o(.text+0x0):/usr/lib/qt-3.3/include/qglist.h:150: first defined here
    17. qdoublebutton.o(.text+0x3a): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    18. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.cxx:16: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    19. app4lin.o(.text+0x3a):./qtrackingbutton.cxx:16: first defined here
    20. qdoublebutton.o(.text+0x74): In function `QTrackingButton::mouseMoved()':
    21. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.cxx:25: multiple definition of `QTrackingButton::mouseMoved()'
    22. app4lin.o(.text+0x74):./qtrackingbutton.cxx:25: first defined here
    23. qdoublebutton.o(.text+0x7a): In function `QTrackingButton::mouseMoveEvent(QMouseEvent*)':
    24. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.cxx:20: multiple definition of `QTrackingButton::mouseMoveEvent(QMouseEvent*)'
    25. app4lin.o(.text+0x7a):./qtrackingbutton.cxx:20: first defined here
    26. qdoublebutton.o(.text+0x80): In function `QDoubleButton::QDoubleButton(QWidget*, char*)':
    27. /home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.cxx:3: multiple definition of `QDoubleButton::QDoubleButton(QWidget*, char*)'
    28. app4lin.o(.text+0x80):./qdoublebutton.cxx:3: first defined here
    29. qdoublebutton.o(.text+0x266): In function `QDoubleButton::QDoubleButton(QWidget*, char*)':
    30. /home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.cxx:3: multiple definition of `QDoubleButton::QDoubleButton(QWidget*, char*)'
    31. app4lin.o(.text+0x266):./qdoublebutton.cxx:3: first defined here
    32. qdoublebutton.o(.text+0x44a): In function `QDoubleButton::clicked()':
    33. /home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.cxx:16: multiple definition of `QDoubleButton::clicked()'
    34. app4lin.o(.text+0x4ee):./qdoublebutton.cxx:16: first defined here
    35. qdoublebutton.o(.text+0x540): In function `QDoubleButton::moused()':
    36. /home/twey/devel/cpp/qt/hts/app4lin/qdoublebutton.cxx:21: multiple definition of `QDoubleButton::moused()'
    37. app4lin.o(.text+0x5e4):./qdoublebutton.cxx:21: first defined here
    38. qtrackingbutton.o(.text+0x0): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    39. /usr/lib/qt-3.3/include/qglist.h:150: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    40. app4lin.o(.text+0x0):app4lin.cxx: first defined here
    41. qtrackingbutton.o(.text+0x3a): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    42. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.cxx:16: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    43. app4lin.o(.text+0x3a):./qtrackingbutton.cxx:16: first defined here
    44. qtrackingbutton.o(.text+0x74): In function `QTrackingButton::mouseMoved()':
    45. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.cxx:25: multiple definition of `QTrackingButton::mouseMoved()'
    46. app4lin.o(.text+0x74):./qtrackingbutton.cxx:25: first defined here
    47. qtrackingbutton.o(.text+0x7a): In function `QTrackingButton::mouseMoveEvent(QMouseEvent*)':
    48. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.cxx:20: multiple definition of `QTrackingButton::mouseMoveEvent(QMouseEvent*)'
    49. app4lin.o(.text+0x7a):./qtrackingbutton.cxx:20: first defined here
    50. moc_qdoublebutton.o(.text+0x0): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    51. /usr/lib/qt-3.3/include/qglist.h:150: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    52. app4lin.o(.text+0x0):app4lin.cxx: first defined here
    53. moc_qdoublebutton.o(.text+0x3a): In function `QTrackingButton::QTrackingButton(QString, QWidget*, char*)':
    54. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.cxx:16: multiple definition of `QTrackingButton::QTrackingButton(QString, QWidget*, char*)'
    55. app4lin.o(.text+0x3a):./qtrackingbutton.cxx:16: first defined here
    56. moc_qdoublebutton.o(.text+0x74): In function `QTrackingButton::mouseMoved()':
    57. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.cxx:25: multiple definition of `QTrackingButton::mouseMoved()'
    58. app4lin.o(.text+0x74):./qtrackingbutton.cxx:25: first defined here
    59. moc_qdoublebutton.o(.text+0x7a): In function `QTrackingButton::mouseMoveEvent(QMouseEvent*)':
    60. /home/twey/devel/cpp/qt/hts/app4lin/qtrackingbutton.cxx:20: multiple definition of `QTrackingButton::mouseMoveEvent(QMouseEvent*)'
    61. app4lin.o(.text+0x7a):./qtrackingbutton.cxx:20: first defined here
    62. moc_qtrackingbutton.o(.text+0x286): In function `QTrackingButton::mouseMoved()':
    63. /home/twey/devel/cpp/qt/hts/app4lin/moc_qtrackingbutton.cpp:80: multiple definition of `QTrackingButton::mouseMoved()'
    64. app4lin.o(.text+0x74):./qtrackingbutton.cxx:25: first defined here
    65. /usr/bin/ld: Warning: size of symbol `QTrackingButton::mouseMoved()' changed from 5 in app4lin.o to 31 in moc_qtrackingbutton.o
    66. collect2: ld returned 1 exit status
    67. make: *** [app4lin] Error 1
    To copy to clipboard, switch view to plain text mode 
    Project file:
    ################################################## ####################
    # Automatically generated by qmake (1.07a) Sat Jan 14 12:22:56 2006
    ################################################## ####################

    TEMPLATE = app
    INCLUDEPATH += .

    # Input
    HEADERS += qdoublebutton.h qtrackingbutton.h
    SOURCES += app4lin.cxx qdoublebutton.cxx qtrackingbutton.cxx
    /EDIT: there really ought to be scrollbars on those [quote] boxes.
    Last edited by Twey; 14th January 2006 at 13:29. Reason: Used [code] tags instead of [quote].

  6. #6
    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

  7. #7
    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

  8. #8
    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.

  9. #9
    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 

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 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,
    _

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

    Default Re: Function previously defined in created file?

    Nope, got them.

  12. #12
    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

  13. #13
    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...

  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?

    Apparently that was the problem

  15. #15
    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 :-\

  16. #16
    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.

  17. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 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.

  18. #18
    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.

  19. #19
    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.

  20. #20
    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
    Also, yop, when the second button in your code (b2) is connected to the moused() slot, nothing happens.
    I only tried to compile not add any functionality

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.