Results 1 to 11 of 11

Thread: Q_OBJECT error

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Q_OBJECT error

    Ok thanks.

    But when i try to include the Q_OBJECT macro i get those errors ?

  2. #2
    Join Date
    Oct 2007
    Location
    Cracow
    Posts
    56
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Q_OBJECT error

    do you place Q_OBJECT in private section of your class ?
    and remeber that your class should inherit someway from QObject class

  3. #3
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Q_OBJECT error

    There must be an earlier problem - the lines you post don't tell us anything. Also you did not tell us how you create the makefile. If you're using qmake then also show us your pro-File.

  4. #4
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Q_OBJECT error

    Did you also make sure that your class derives from QObject (either directly or indirectly)?
    Vycke

  5. #5
    Join Date
    May 2008
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Q_OBJECT error

    I have edited my original post to show the code for my class and for my .pro file. Although i am not that clear yet on the purpose of the .pro file.

  6. #6
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Q_OBJECT error

    Did you rerun qmake after you added Q_OBJECT to your header?
    And what's the actual error - as I said the error message you gave us isn't the first one you see and we can't say anything about the real problem.
    The pro-file looks fine.

    OT: But why did you put the implementation into the header? This isn't a good coding style.

  7. #7
    Join Date
    May 2008
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Q_OBJECT error

    Hi, thnanks for your time.

    I put the implementation in the header, becauase when I do not i get an additional error message. Even if it is all in the same file.

    undefined reference to `vtable for Window'

    Also I am new to eclipse and qt, This might sound dumb but am I not rerunning qmake when i save the source and build all and run? or do i need to do something else.

    Thanks

  8. #8
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Q_OBJECT error

    You have to rerun qmake every time you add/remove Q_OBJECT in an header - otherwise qmake can't create the moc calls for the headers and you get a vtable linker error.

  9. #9
    Join Date
    May 2008
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Q_OBJECT error

    How do I rerun qmake and what files do i need to pass.
    Or does qmake get invoked by eclipse everytime I do a build project?

    I tried this on cmd but I still get the errors.

    qmake -makefile -win32 C:/Eclipse/buttonTest/buttonTest.pro
    qmake -project -win32 C:/Eclipse/buttonTest/buttonTest.pro

    and they both didn't output any errors when i run them. But still errors when i try to build the project.

    Sorry my understanding is low.
    Last edited by Toshikazu; 28th May 2008 at 04:15.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  5. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19

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
  •  
Qt is a trademark of The Qt Company.