質問

How to highlight the pixels in a QImage to highlight or draw a overlay on the pixels which user selected using mouse. I just want to know how i can specify the particular area.

Ex: With a 400x400 QImage data how i can increase or decrease the pixel intensity or overlap an image on top of it where the user selected.

役に立ちましたか?

解決

You can involve QPainter (please refer to the documentation) to draw over your QImage. It allows drawing another images, rectangles, lines etc.

void View::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);

    // Draws your original image.
    painter.drawImage(0, 0, myImage);

    // Draws a blue rectangle over the image.
    QPen rectPen(Qt::blue);
    rectPen.setStyle(Qt::DashLine);
    painter.setPen(rectPen);
    painter.drawRect(0, 0, 100, 100);
    [..]
}

You can maintain your mouse clicks and movement and draw corresponding stuff in paint event handler.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top