Answer the question
In order to leave comments, you need to log in
Qtextedit - how to work with setText, setHtml as slots?
I study qt at the initial stage.
There is a code (slightly modified from Max Schlee's book):
#include <QtWidgets>
// ----------------------------------------------------------------------
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QTextEdit* txt = new QTextEdit;
QTextEdit* txttwo = new QTextEdit;
QWidget wgt;
QLabel* lbl = new QLabel;
QString stri = "123";
txt->setHtml("<HTML>"
"<BODY BGCOLOR=MAGENTA>"
"<H2><CENTER>Gnome Poem 3: Magic Magic</CENTER></H2>"
"<FONT COLOR=BLUE>"
"<P ALIGN=\"center\">"
"<I>"
"Magic! Magic!<BR>"
"Are you here?<BR>"
"Abra-ca-dabra!<BR>"
"We appear.<BR><BR>"
"Magic! Magic!<BR>"
"Gnomes are we.<BR>"
"Magic gnomes<BR>"
"Of mystery.<BR>"
"..."
"</I>"
"</P>"
"</FONT>"
"</BODY>"
"</HTML>"
);
txttwo->setText(txt->toHtml());
//QObject::connect(txttwo,SIGNAL(textChanged()), txt,SLOT(clear()));
QObject::connect(txttwo,SIGNAL(textChanged()), txt,SLOT(setHtml(stri)));
QHBoxLayout* pvv = new QHBoxLayout;
pvv->addWidget(txttwo);
pvv->addWidget(txt);
pvv->addWidget(lbl);
wgt.setLayout(pvv);
wgt.show();
return app.exec();
}
QObject::connect: No such slot QTextEdit::setHtml("123") in ..\TextEdit\main.cpp:55
Answer the question
In order to leave comments, you need to log in
Please close the question. I found a very stupid mistake, I should have read the description of connect normally
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question