2

I am trying to make it to where redo is only visible after undo is used. I cannot seem to get it to work. I know there is something wrong with my signals and slots i just cant figure out how to get it to work.

here is the code for the undo and redo signal slots:

    cutAct->setEnabled(false);
    copyAct->setEnabled(false);
    undoAct->setVisible(false);
    redoAct->setVisible(false);
    connect(textEdit, SIGNAL(copyAvailable(bool)), cutAct, SLOT(setEnabled(bool)));
    connect(textEdit, SIGNAL(copyAvailable(bool)), copyAct, SLOT(setEnabled(bool)));
    connect(textEdit->document(), SIGNAL(modificationChanged(bool)), undoAct, SLOT(setVisible(bool)));
    connect(undoAct, SIGNAL(triggered()), redoAct, SLOT(setVisible(bool)));
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
Zach Starnes
  • 3,108
  • 9
  • 39
  • 63
  • In general, you may not have less (or different) parameters in the SIGNAL than in the SLOT. You should have a warning in the command line saying something like that. Apart from that, opc0de's answer should be the solution to your problem. – Tim Meyer Oct 24 '12 at 10:54

1 Answers1

2
ui->undoBtn->setEnabled(false);
ui->redoBtn->setEnabled(false);
connect(ui->textEdit,SIGNAL(redoAvailable(bool)),ui->redoBtn,SLOT(setEnabled(bool)));
connect(ui->textEdit,SIGNAL(undoAvailable(bool)),ui->undoBtn,SLOT(setEnabled(bool)));

Put it in the constructor and the undo and redo buttons will become available when is action for them

opc0de
  • 11,557
  • 14
  • 94
  • 187