Я пытаюсь нарисовать только левую границу в QTextDocument. Поскольку afaik QTextFrame не поддерживает выборочную границу, я пытаюсь назначить текстурированную кисть для текстового фрейма. Что-то вроде следующего -
#include <QPainter>
#include <QTextFrameFormat>
#include <QTextCursor>
#include <QTextFrame>
#include <QTextEdit>
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QTextDocument doc;
QPixmap map(1024, 1024);
QPainter p;
p.begin(&map);
p.setBackground(QBrush(Qt::transparent));
p.drawRect(QRect(0,0, 4, map.height()));
p.end();
QTextFrameFormat frameFormat;
QBrush bruh(map);
bruh.setColor(Qt::transparent);
frameFormat.setBackground(bruh);
auto cur = new QTextCursor(&doc);
auto frame = cur->insertFrame(frameFormat);
auto curf = new QTextCursor(frame);
curf->insertText("Hello this is qt program!");
QTextEdit e;
e.setDocument(&doc);
e.show();
return a.exec();
}
Но это печатает черный фон, даже если фон установлен прозрачным (мне нужен прозрачный фон только с красной рамкой слева).
Я не могу понятьчто не так. Кроме того, может ли быть любой другой способ иметь только левую границу для QTextFrame?
![enter image description here](https://i.stack.imgur.com/acFhB.png)