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. [solved] Drawing on top of an image
QtWS25 Last Chance

[solved] Drawing on top of an image

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 5.4k Views
  • 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.
  • T Offline
    T Offline
    ThaRez
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      ThaRez
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • AlicemirrorA Offline
        AlicemirrorA Offline
        Alicemirror
        wrote on last edited by
        #3

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

        Enrico Miglino (aka Alicemirror)
        Balearic Dynamics
        Islas Baleares, Ibiza (Spain)
        www.balearicdynamics.com

        1 Reply Last reply
        0
        • AlicemirrorA Offline
          AlicemirrorA Offline
          Alicemirror
          wrote on last edited by
          #4

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

          Enrico Miglino (aka Alicemirror)
          Balearic Dynamics
          Islas Baleares, Ibiza (Spain)
          www.balearicdynamics.com

          1 Reply Last reply
          0
          • T Offline
            T Offline
            ThaRez
            wrote on last edited by
            #5

            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();
            scene->addPixmap(QPixmap("C:/test/ab.png"));
            
            ui->graphicsView->setScene(scene);
            ui->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
            

            @

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

            B.R.
            Richard

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

            1 Reply Last reply
            0
            • AlicemirrorA Offline
              AlicemirrorA Offline
              Alicemirror
              wrote on last edited by
              #6

              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 :)

              Cheers,
              Enrico

              Enrico Miglino (aka Alicemirror)
              Balearic Dynamics
              Islas Baleares, Ibiza (Spain)
              www.balearicdynamics.com

              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