PDA

View Full Version : signal problem



brantyou
15th September 2010, 16:08
I want to send a signal in a slot.The code like:

void MainQtWidget::GetTextMsg(){
*val = MainTextEdit->toPlainText();//get QLineEdit text
emit this->FromQtToCoreSignal(&val);
}

GetTextMsg() is a slot,about this code:

MainTextEdit = new QTextEdit("Waiting for enter!");
connect(MainSureButton, SIGNAL(clicked()), this, SLOT(GetTextMsg()));


It runs' problem:
The program has unexpectedly finished.

debug problem:
The inferior stopped because it received a signal from the Operating System.

Signal name :
SIGSEGV
Signal meaning :
Segmentation fault



How can I do? Could you tell me what mistake I have make?
Thanks very much!

tbscope
15th September 2010, 16:12
I want to send a signal in a slot.The code like:


*val = MainTextEdit->toPlainText();//get QLineEdit text



What is this?

brantyou
15th September 2010, 16:15
to get the QLineEdit text and save in val which defined like QString *val;

tbscope
15th September 2010, 16:20
Does this even compile?

Anyway, QLineEdit doesn't have any toPlainText() function since it can only contain plain text.

Why don't you simply do something like this?

void MyClass::mySlot()
{
emit mySignal(myLineEdit->text());
}

brantyou
15th September 2010, 16:26
Can it send the text that I just had enterd? I try it at once.Thanks for you help!My English is not good,so much time can't make others known my mind!:p

brantyou
15th September 2010, 16:34
I try it . It didn't work. Because I can't find the text() in myLineEdit.
myLineEdit->text() the text() is invalid.