Qt style sheets are ideal for achieving what you want.
The solution is to use a border image. Fortunately, you can do this using the stylesheets and the QTextEdit style.
About QTextBlock or QTextFrame : QTextEdit is a widget that displays a QTextDocument that can contain a QTextBlock and a QTextFrame . Frames and blocks are text containers that provide the structure of text in a document, but they are not displayed as separate widgets. For this reason, they cannot be developed independently of each other. I recommend using QTextEdit or another widget for each message and properly managing the subsequent increase in memory usage.
I will show how to style text editing.
First make a clean image of the desired border. Using a small photoshop, I prepared my own image (not as clean as it should be for a production application):

Allows style objects of the QTextEdit class and its subclasses.
QTextEdit { background-color: #eaedf2; border-image: url(":/images/bkg.png"); border-top-width: 11px; border-right-width: 4px; border-bottom-width: 4px; border-left-width: 11px; }
Installing the previous stylesheet in the text edit container will turn all of them into this

Something similar to your desired look. Of course, you should prepare a good image of the border and better adjust the size of the border, but I think this can help.
If you want to use different styles for incoming and outgoing messages, you will have to correctly distinguish them and select them in the stylesheet. Check this out for reference.
source share