Qt World Summit: Register Today!

[solved] Drawing on top of an image

  • Hello
    I would like to draw rectangles on top of an image, but so that they remain as elements of their own, allowing me to select them as well as to remove them.

    So far I've added an label with an attached pixmap, adding an Qpainter to the image and then drawing on top of this. However, if I understand it correctly (new to qt) this will draw on to the pixmap itself making the image static. I would like the rectangles to "float" on top of the image so that I could select them and have action attached to them (among other to delete them). Also I'd like a "lasso like" effect when drawing the rectangles.

    I'd appreciate any tips how to proceed. :) Thank you!

  • Found some information about how to use a graphicsview to complete this task. Unfortunately I can't post the solution as it's in a book.

  • But you can cite the concept ;) and the direction of your solution.

  • And, obviously, the book bibliography too. We all can read :D

  • A book that has the GraphicView well documented (for my purpose, in my opinion) is:

    C++ GUI Programming with Qt4, Second edition
    ISBN: 0132654160

    The principle was to create a QGraphicsView and a scene on top of which different graphics elements can be created and managed independently.
    ui->setupUi(this); // QGraphicsView added via designer

    scene = new QGraphicsScene();


    Still working out the details of the individual elements...


    [edit : please use @ tags around your code as I did for you, Eddy]

  • Many thanks, this is really useful. I have a lot of book on C++ but this maybe a idea. I am approaching to develop some GUI stuff in a multiplatform environment :)


Log in to reply