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:
void FramesEditor::emitSetNewActiveFrame(Frame *frame){
emit setNewActiveFrame(frame);
}
void FramesEditor::emitSetNewActiveFrame(Frame *frame){
emit setNewActiveFrame(frame);
}
To copy to clipboard, switch view to plain text mode
and in the using code:
void FrameManager::setCurrentActiveFrame(int frameID)
{
qDebug()<<">>> frameManager.cpp : currentActiveFrame ID : "<<currentActiveFrame;
Frame *activeFrame = frameBank[keyStartFrame];
if(frameBank.contains(frameID)){
currentActiveFrame = frameID;
activeFrame = frameBank[currentActiveFrame];
}
qDebug()<<">>> frameManager.cpp : currentActiveFrame ID updated: "<<currentActiveFrame;
//emit (FramesEditor::getInstance())->setNewActiveFrame(activeFrame); //causing error
FramesEditor::getInstance()->emitSetNewActiveFrame(activeFrame);
}
void FrameManager::setCurrentActiveFrame(int frameID)
{
qDebug()<<">>> frameManager.cpp : currentActiveFrame ID : "<<currentActiveFrame;
Frame *activeFrame = frameBank[keyStartFrame];
if(frameBank.contains(frameID)){
currentActiveFrame = frameID;
activeFrame = frameBank[currentActiveFrame];
}
qDebug()<<">>> frameManager.cpp : currentActiveFrame ID updated: "<<currentActiveFrame;
//emit (FramesEditor::getInstance())->setNewActiveFrame(activeFrame); //causing error
FramesEditor::getInstance()->emitSetNewActiveFrame(activeFrame);
}
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.
Bookmarks