Hi guys,QTextEdit Insert a picture and text in one line.How to make the text in the center of a line.
Asked
Active
Viewed 407 times
0
-
try to reduce the height of your image. – Gabrielle de Grimouard Apr 01 '17 at 11:16
-
thanks,Is there any other way?I use QTextBrowser display text and picture – juis jing Apr 01 '17 at 11:35
-
with a QLineEdit, that's won't be easy. maybe you can try to create a class inheriting to QLineEdit and overload the paint method. in that method you would be able to draw the text and move the image where you want it to be. But it's not so clean for what you wanna do and I think that it will be way easier for you to have smiley with the same height than your text – Gabrielle de Grimouard Apr 01 '17 at 11:49
1 Answers
0
I have solved this problem,thanks
QTextImageFormat imageFormat;
imageFormat.setWidth(image.width());
imageFormat.setHeight(image.height());
//center the image
imageFormat.setVerticalAlignment(QTextImageFormat::AlignMiddle);
imageFormat.setName(file);
cursor.insertImage(imageFormat);
ui->textEdit_Send->setFocus(Qt::MouseFocusReason);

juis jing
- 55
- 1
- 8