Results 1 to 3 of 3

Thread: Qt signal error : undefined reference to 'FramesEditor::setNewActiveFrame(Frame *)' ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt signal error : undefined reference to 'FramesEditor::setNewActiveFrame(Frame *

    I don't have the time to look at the emit implmentation, but I don't think emit can do what your code is telling it.
    As far as I know, emit needs a signature of an empty method defined as a signal (that moc then translates to calls in an meta object).

    One why to do it is to wrap the signal emitting in your singleton:
    Something like this:
    Qt Code:
    1. void FramesEditor::emitSetNewActiveFrame(Frame *frame){
    2. emit setNewActiveFrame(frame);
    3. }
    To copy to clipboard, switch view to plain text mode 

    and in the using code:

    Qt Code:
    1. void FrameManager::setCurrentActiveFrame(int frameID)
    2. {
    3. qDebug()<<">>> frameManager.cpp : currentActiveFrame ID : "<<currentActiveFrame;
    4. Frame *activeFrame = frameBank[keyStartFrame];
    5.  
    6. if(frameBank.contains(frameID)){
    7. currentActiveFrame = frameID;
    8. activeFrame = frameBank[currentActiveFrame];
    9. }
    10. qDebug()<<">>> frameManager.cpp : currentActiveFrame ID updated: "<<currentActiveFrame;
    11.  
    12. //emit (FramesEditor::getInstance())->setNewActiveFrame(activeFrame); //causing error
    13. FramesEditor::getInstance()->emitSetNewActiveFrame(activeFrame);
    14. }
    To copy to clipboard, switch view to plain text mode 

    You will also need to update your connect().
    But there is also a deisgn issue here.
    You are emitting a signal defined in FramesEditor from FrameManager, which is possible as I have shown but points to a design flaw.
    Since signals are only messages, they should be defined by the signaling object.
    So I don't see why this signal is defined in FramesEditor and not in FrameManager.
    That is probably the best line of action - move the signal to FrameManager since it is the class actually emitting the signal.
    Last edited by high_flyer; 1st March 2018 at 11:02.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. The following user says thank you to high_flyer for this useful post:

    keshav2010 (1st March 2018)

  3. #2
    Join Date
    Jan 2018
    Location
    India, Delhi
    Posts
    10
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt signal error : undefined reference to 'FramesEditor::setNewActiveFrame(Frame *

    Thanks for pointing out the design flaw, and also updated connect to a newer syntax. That fixed the issue

Similar Threads

  1. Android undefined reference to signal,sigfillset,stpcpy...
    By sifourquier in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 15th August 2016, 15:02
  2. Replies: 2
    Last Post: 11th August 2012, 17:37
  3. Undefined reference to signal
    By chinalski in forum Qwt
    Replies: 8
    Last Post: 29th July 2012, 19:05
  4. Undefined reference to my signal
    By tomek in forum Newbie
    Replies: 9
    Last Post: 1st December 2011, 07:14
  5. Undefined Reference error!!!
    By Kapil in forum Newbie
    Replies: 25
    Last Post: 28th March 2006, 12:03

Tags for this Thread

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.