Results 1 to 8 of 8

Thread: function 'connect' always look super class for slots.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: function 'connect' always look super class for slots.

    Quote Originally Posted by Intaek Lim View Post
    But when I add that macro, there are some link errors. What library should I add?
    That's why I suggested re-running qmake. The required moc steps are missing. For signals and slots, an auto-generated piece of code must be compiled and linked. Adding the Q_OBJECT macro and re-running qmake takes care of this.

    But, I see you are using Visual Studio. Do you have a commercial license and the Visual Studio integration? I think the commercial integration should take care of detecting an added Q_OBJECT macro automatically, but if you are using an open source version and the community patches, you might need to regenerate the Visual Studio project file or something.
    J-P Nurmi

  2. #2
    Join Date
    Mar 2007
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: function 'connect' always look super class for slots.

    Thank for your reply, but I don't know to qmake in WinXP environ. with VS2005.

  3. #3
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: function 'connect' always look super class for slots.

    Quote Originally Posted by Intaek Lim View Post
    Thank for your reply, but I don't know to qmake in WinXP environ. with VS2005.
    Create a seperate *.h and *.cpp file. Put your declarations in *.h and definations in *.cpp. Use Q_OBJECT macro defore defining your constructor in *.h file and before public specifier. Hit the "moc" button provided with vs-integration(which you can see at top after you have installed qt properly).

    This should solve the problem.

  4. #4
    Join Date
    Jul 2006
    Location
    Poprad/Prague
    Posts
    33
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: function 'connect' always look super class for slots.

    I'm not really sure, if I know what the problem exactly is, but some suggestions:

    You should put Q_OBJECT macro inside your class and re-run qmake, but one other question crossed my mind: Did you put your function in 'public/private slots' section of the class?

  5. #5
    Join Date
    Mar 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: function 'connect' always look super class for slots.

    if your MyWindow has more than one parent make sure that QMainWindow listed first:

    class MyWindow: public QMainWindow,public AnyOtherParents

    otherwise moc will parse it incorrectly.

Similar Threads

  1. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04
  2. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  3. Problems calling C function in C++/Qt class
    By Rayven in forum General Programming
    Replies: 2
    Last Post: 2nd June 2006, 21:32
  4. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52
  5. virtual overloaded functions and base class function call...
    By nouknouk in forum General Programming
    Replies: 7
    Last Post: 11th March 2006, 21:26

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.