Adding QTextEdit on QPixmap



  • Hi all, I am implementing a screen capture application. In this app, I need to be able to select an area of the screen and set it to the background pixmap of a label, on which I can then draw images and edit text, and finally save this this modified screen capture into a file.

    Right now, I have finished most parts of this app. I first set the selected screen area as a label's pixmap, then copy this pixmap out and draw images on it with QPainter(QPixmap *), finally reset the label's pixmap with this modified one. This works well for drawing images like lines, rectangles and ellipses, but not for text editing, because the constructor of QTextEdit does not support QPaintDevice as its parent. As a result, although I can insert and display QTextEdit on the label, I can't save it with pixmap.save(). (I have to save label image by pixmap because I stored a stack of pixmaps in a QStack so that I can go back and restore to the last pixmap.)

    I tried to use painter.drawText() with input from QTextEdit, but this doesn't work very well, because I can't make the positions of painter.drawText coincide with the text content of QTextEdit. (Sorry, It's a complex process and I can't explain it clearly with mere words)

    Could anyone give some suggestions?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.