Important: Please read the Qt Code of Conduct -

(QScrollArea + QLabel) OR (QGraphicsView + QGraphicsScene)?

  • Greetings.

    I'm building an application that should display an image and allows the user to pinpoint regions/objects of interest in image. This is done interactively by drawing rectangles on region the user indicated using the mouse. It should be possible too resized the rectangles drawn on the image using the mouse (similar to image editing software like MS Paint). More specifically, the user should be able to:

    (A) Mark an area or object in the image with a rectangle that you draw on the image when the user clicks the left mouse button on a point in the image and move the mouse while holding pressed the left mouse button until release it. The drawn rectangle is defined by the point where you click and the point where the left mouse button is released.

    (B) Resize an already marked rectangle by clicking with the left mouse button on one rectangle corner and move the mouse while the left mouse button is kept pressed until it is released. The final rectangle will be defined by the point where the left mouse button is released and the point corresponding to the opposite corner of the rectangle to the corner on which I clicked.

    Also, I should be able to zoom in/zoom out on the image. Here, when zooming, the marked rectangles should fit properly.

    My questions here are on the set Qt classes I must use (or more precisely, which Qt classes are more appropriate) for this task. It occurs to me:

    1. QGraphicView + QGraphicScene, along with some other classes as QGraphicsRectItem.

    2. QScrollArea + QLabel or rather a subclass of QLabel in which I reimplement paint functions and event handlers to allow the user to mark regions of interest.

    3. Any other (better) option?

    In particular, I don't know if the alternatives I have listed here are the best for this job or which of the two of them is the best option.

    Thanks in advance for any help and / or suggestions.

Log in to reply