Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding QTextEdit on QPixmap
Forum Updated to NodeBB v4.3 + New Features

Adding QTextEdit on QPixmap

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 676 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David406
    wrote on last edited by David406
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved