I am trying to create a QTextDocument with only a left border around the text. I believe the necessary CSS for this would be:
<div style='
border-left: 6px solid red;
background-color: lightgrey;
'> Hello World </div>
However, when implementing this in my Qt code as shown below:
#include <QApplication>
#include <QWidget>
#include <QHBoxLayout>
#include <QTextEdit>
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QWidget *widget = new QWidget();
auto l = new QHBoxLayout(widget);
widget->setLayout(l);
QTextEdit *e = new QTextEdit(widget), *t = new QTextEdit(widget);
l->addWidget(e);
l->addWidget(t);
QObject::connect(e, &QTextEdit::textChanged, [=]() {
t->setHtml(e->toPlainText());
});
widget->show();
}
When entering HTML content, the output is not as expected:
https://i.sstatic.net/Rsn1M.png
The desired output should look like this:
https://i.sstatic.net/MswGr.png
I want to achieve the desired output - Is there something I am missing?