Je programme:Comment insérer du html dans QTextEdit à partir du presse-papier via ctrl + V?
int main(int argc, char *argv[]){
QApplication app(argc, argv);
QTextEdit te;
te.setHtml("<!DOCTYPE html>"
"<html>"
"<body style = \"background-color:powderblue;\">"
"<h1>My First Heading</h1>"
"<p>My first paragraph.</p>"
"</body>"
"</html>");
te.resize(500, 300);
te.show();
return app.exec();
}
Ce programme crée la fenêtre suivante:
J'ai un autre programme:
int main(int argc, char *argv[]){
QApplication app(argc, argv);
QTextEdit te;
te.resize(500, 300);
te.show();
return app.exec();
}
Mais si je copie le texte
<!DOCTYPE html>
<html>
<body style="background-color:powderblue;">
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>
du presse-papier en appuyant sur Ctrl + V dans la fenêtre créée par le programme, je vois:
Comment puis-je réécrire mon programme pour afficher html comme dans la première image?
Pas facile de dire si vous ne vous présentez pas le code. Le comportement est-il différent lorsque vous tapez le texte au lieu de le coller? – KjMag
Informations sur http://doc.qt.io/qt-5/qclipboard.html – hyde
Vous pouvez également lire http://doc.qt.io/qt-5/qtextedit.html#insertFromMimeData – hyde