0

I have a class Historymanager, that has an attribute of type QUndoStack. I can get the undoStack with a getter that returns

QSharedPointer<QUndoStack>

Now in a different class C, I have access to the historymanager and need to connect the signal canRedoChanged(bool) to a method from that class. The problem is: How do I tell the connect method the sender?

I tried:

        connect((historyManager->getQUndoStack().data()),
                 SIGNAL(canRedoChanged()), this, SLOT(onCanRedoChanged()));

but that doesn't do the trick. I also tried

           connect(*(historyManager->getQUndoStack().data()),
                 SIGNAL(canRedoChanged()), this, SLOT(onCanRedoChanged()));

to dereference the historyManager->getQUndoStack().data() by putting a "*" before, but that gives a compile error.

The way it is now Qt keeps telling me that there is no signal canRedoChanged, even though qundostack.h definitely provides it. The connect method requires the first argument to be

 const QObject *sender

What do I need to do here?

demonplus
  • 5,613
  • 12
  • 49
  • 68
RunOrVeith
  • 4,487
  • 4
  • 32
  • 50
  • *that doesn't do the trick* why not? What error do you get? – peppe Feb 08 '15 at 18:54
  • not an error, but when I run the application it says that there is no signal called canRedoChanged: Object::connect: No such signal QUndoStack::canRedoChanged() Object::connect: (receiver name: 'actionControllerWidget'). It seems like I had to specify the bool parameter in the signal and Slot, even though the Signals & Slots Documentation says you don't have to. – RunOrVeith Feb 08 '15 at 19:04
  • 1
    At least, you should specify it for the signal name. Then the slot is indeed allowed to drop argoments it doesn't need. But the signal without parameter simply doesn't exist. – peppe Feb 08 '15 at 19:08

0 Answers0