Results 1 to 5 of 5

Thread: Problem with Q_Object and XCode

  1. #1
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Problem with Q_Object and XCode

    Hello everyone,

    I've been using Qt 4.3 successfully with XCode for a while. Now I had to use signals and slots and to implement these I have to use the Q_Object macro. However, as soon as I include the macro, XCode won't build my project any more. It reports an error during Linking that reads like this:

    Qt Code:
    1. x 'vtable for MyDialog', referenced from:
    2. __ZTV8MyDialog$non_lazy_ptr in MyDialog.o
    3. symbol(s) not found
    4. collect2: Id returned 1 exit status
    5. Build failed (1 error)
    To copy to clipboard, switch view to plain text mode 

    I don't know why I get this error. It probably is something stupid, as the exact same project compiles and runs perfectly on Windows XP with Eclipse.

    Please, can anyone turn me in the right direction?
    I had this problem before and was not able to solve it. The Qt-Demo-Projects using Q_Object compile and run fine...

    Any help?

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

    Default Re: Problem with Q_Object and XCode

    You need to rerun qmake when you add the Q_OBJECT macro to a file.

  3. #3
    Join Date
    Jan 2007
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Problem with Q_Object and XCode

    Thanks, that did something and added the moc-file to the project. However, I get now several other Linker errors - see Attachment.

    Also, can't I rerun qmake and NOT loose my existing XCode-Project settings? I've customized several targets etc., automatically including the Qt Framework etc. It's quite a bit of work to recreate all that each time I have to run qmake for something like this...

    I was finally able to get the project to work, but only by deleting most of the contents in my projects folder, including the project file, generating a new project file and then running qmake. But please - there GOT to be a better way to do this!
    Attached Images Attached Images

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

    Default Re: Problem with Q_Object and XCode

    Quote Originally Posted by bjoernbg View Post
    Thanks, that did something and added the moc-file to the project. However, I get now several other Linker errors - see Attachment.
    Check if you have those methods implemented.

    Also, can't I rerun qmake and NOT loose my existing XCode-Project settings?
    No idea. As far as I know qmake can generate an xcode project file for you, but in general an existing project (generated by qmake) should be able to handle files containing Q_OBJECT. Otherwise you have to implement some rule for xcode yourself that runs moc on appropriate files.

  5. #5
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Problem with Q_Object and XCode

    When I add new files to my project on a Mac I just delete old xcode project and generate new one. Usually this helps
    C++ & AMD forever

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.