1

I need to display a text in a QTextEdit after I clicked on a button.

I have:

QGroupBox *groupDefClass = new QGroupBox("Definition of the class");
QFormLayout *formDefClass = new QFormLayout;
QLineEdit *name = new QLineEdit;
QLineEdit *motherClass = new QLineEdit;

formDefClass->addRow("&Name:", name);
formDefClass->addRow("Mother Class :", motherClass);
groupDefClass->setLayout(formDefClass);

QVBoxLayout *vertBoxAll = new QVBoxLayout;
vertBoxAll->addWidget(groupDefClass);

Then I have another textBox somewhere else:

textResult = new QTextEdit();
vertBoxAll->addWidget(textResult);

And I wanted to add the "code" using this button:

generButton = new QPushButton("Generate...");
connect(generButton, SIGNAL(clicked()), this, SLOT(getData(code)));

And the getData:

void SetUpPage::getData(QString code) {
    textResult->setPlainText(code);
    textResult->setReadOnly(true);
    textResult->setFont(QFont("Courier"));
    textResult->setLineWrapMode(QTextEdit::NoWrap);
}

But nothing happens.

I also tried to add textResult->setPlainText(code) directly in the SLOT (not sure if I can do that) but still nothing.

I really don't see what I'm doing wrong. Thanks in advance for your help.

Laurent

Laurent
  • 188
  • 2
  • 13

1 Answers1

0

1) This SLOT(getData(code)) contains error - replace code with QString.

2) Launch under debugger and catch this error at runtime. Call qInstallMessageHandler and show message boxes to force similar errors be shown without debugger.

3) Use function-pointer signal/slot connect to prevent this kind of errors in future.