Bender_Rodriguez
13th April 2013, 01:53
Hi, everybody!
Please, help me.
There is a small problem with my code.
Well, the first part of the code I took from one famous book.
So, I decided to make the second part myself.
But it doesn't work...
The problem is in the connect statement :
ui->setupUi(this);
this->setWindowTitle(QString("%1 - %2" ).arg("unnamed").arg("SDI"));
QTextEdit* docWidget = new QTextEdit( this );
setCentralWidget( docWidget );
connect( docWidget->document(), SIGNAL(modificationChanged(bool)),
this, SLOT(setWindowModified(bool)) );
QAction* cutAction = new QAction( QIcon("C:/icon/icon.png"), tr("Cu&t"), this );
cutAction->setShortcut( tr("Ctrl+X") );
cutAction->setStatusTip( tr("Cut") );
cutAction->setEnabled(false);
connect( docWidget, SIGNAL(copyAvailable(bool)),
cutAction, SLOT(setEnabled(bool)) );
connect( cutAction, SIGNAL(triggered()), docWidget, SLOT(cut()));
.......
QAction* pasteAction = new QAction(QIcon("C:/icon/paste.png"), tr("&Paste"), this);
pasteAction->setShortcut(tr("Ctrl+V"));
pasteAction->setStatusTip(tr("Paste"));
pasteAction->setEnabled(false);
connect(..., SIGNAL(...), pasteAction, SLOT(setEnabled(bool)));
connect(pasteAction, SIGNAL(triggered()), docWidget, SLOT(paste()));
I can't understand, which one object (e.g., cutAction, docWidget->document() or this-pointer) should emit which one signal (if exist :) ) to enable pasteAction?
Many thanks.
Please, help me.
There is a small problem with my code.
Well, the first part of the code I took from one famous book.
So, I decided to make the second part myself.
But it doesn't work...
The problem is in the connect statement :
ui->setupUi(this);
this->setWindowTitle(QString("%1 - %2" ).arg("unnamed").arg("SDI"));
QTextEdit* docWidget = new QTextEdit( this );
setCentralWidget( docWidget );
connect( docWidget->document(), SIGNAL(modificationChanged(bool)),
this, SLOT(setWindowModified(bool)) );
QAction* cutAction = new QAction( QIcon("C:/icon/icon.png"), tr("Cu&t"), this );
cutAction->setShortcut( tr("Ctrl+X") );
cutAction->setStatusTip( tr("Cut") );
cutAction->setEnabled(false);
connect( docWidget, SIGNAL(copyAvailable(bool)),
cutAction, SLOT(setEnabled(bool)) );
connect( cutAction, SIGNAL(triggered()), docWidget, SLOT(cut()));
.......
QAction* pasteAction = new QAction(QIcon("C:/icon/paste.png"), tr("&Paste"), this);
pasteAction->setShortcut(tr("Ctrl+V"));
pasteAction->setStatusTip(tr("Paste"));
pasteAction->setEnabled(false);
connect(..., SIGNAL(...), pasteAction, SLOT(setEnabled(bool)));
connect(pasteAction, SIGNAL(triggered()), docWidget, SLOT(paste()));
I can't understand, which one object (e.g., cutAction, docWidget->document() or this-pointer) should emit which one signal (if exist :) ) to enable pasteAction?
Many thanks.