PDA

View Full Version : send the text QCheckBox to QTextEdit



jaca
18th November 2011, 20:38
It is possible when you click a QCheckBox the text () is sent to a QTextEdit?

ChrisW67
18th November 2011, 23:44
Yes, you can program anything you like in a slot connected to the clicked() or stateChanged() signal.

jaca
19th November 2011, 13:03
I was not plain in my question. Sorry my English.
It would be something like:


connect(QCheckBox, SIGNAL(clicked()), QTextEdit, SLOT(insertHtml(QCheckBox->text())));

Clicking on QCheckBox it sends your text() to QTextEdit.
You can do this without derive the class QTextEdit to create a new SLOT?

grin
19th November 2011, 13:29
No, it's impossible, because signatures of signal and slot are not match. (see http://doc.qt.nokia.com/stable/signalsandslots.html - fifth paragraph)


The signature of a signal must match the signature of the receiving slot


You have to define your own slot with signature (void) or (), then connect clicked() signal to this slot. Inside you slot you can create any action.