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. QGraphicsRectItem coordinate system on image resize

QGraphicsRectItem coordinate system on image resize

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgraphicsitemqgraphicssceneresizemapto
3 Posts 2 Posters 1.2k 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.
  • S Offline
    S Offline
    sayan275
    wrote on 24 May 2018, 11:47 last edited by sayan275
    #1

    On an image(x by y), a QGraphicsRectItem is added, Let say Qrect(73, 77, 43, 28) Qrect(x,y,w,h). After resizing the image to 128 by 32, how this QGraphicsRectItem can be redrawn with proper co-ordinates.

    The image is first resized, and then the graphicsRectItem to be added.

    How a qrect can be mapped with respect to the image resized?

    R 1 Reply Last reply 24 May 2018, 18:33
    0
    • S sayan275
      24 May 2018, 11:47

      On an image(x by y), a QGraphicsRectItem is added, Let say Qrect(73, 77, 43, 28) Qrect(x,y,w,h). After resizing the image to 128 by 32, how this QGraphicsRectItem can be redrawn with proper co-ordinates.

      The image is first resized, and then the graphicsRectItem to be added.

      How a qrect can be mapped with respect to the image resized?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 24 May 2018, 18:33 last edited by
      #2

      @sayan275 how do you add the rect item exactly?
      You could add the rect item as a child of the image item for example and simply resize it to the parent boundingRect

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      S 1 Reply Last reply 28 May 2018, 06:39
      0
      • R raven-worx
        24 May 2018, 18:33

        @sayan275 how do you add the rect item exactly?
        You could add the rect item as a child of the image item for example and simply resize it to the parent boundingRect

        S Offline
        S Offline
        sayan275
        wrote on 28 May 2018, 06:39 last edited by sayan275
        #3

        @raven-worx

        I tried the following but didn't work out..

                QGraphicsPixmapItem* item = new QGraphicsPixmapItem(QPixmap::fromImage(qImage, Qt::AutoColor));
                m_ViewerScene->addItem(item);
                QGraphicsRectItem* rect = new QGraphicsRectItem(m_BoundingBox);
                m_ViewerScene->addItem(rect);
                rect->setParentItem(item);
                m_ViewerScene->update();
                //add the resized QGraphicsPixmapItem to the pixmap
                item->setPixmap( item->pixmap().scaled(QSize(128, 32),Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
                qInfo()<<"Rect resize props:::"<<item->childItems()[0]->boundingRect();
                m_BoundingBox = item->childItems()[0]->boundingRect();
        

        later I'm drawing box, on the image in an other viewer, with m_BoundingBox.

        0_1527498444379_Untitled.png
        The grey area within the blue rectangle will be resized to 128 * 32, and then the red rectangle would be added on the resized image. How to get the co-ordinates of red rect on the resized image?

        1 Reply Last reply
        0

        1/3

        24 May 2018, 11:47

        • Login

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