Results 1 to 2 of 2

Thread: problem resizing rect

  1. #1
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question problem resizing rect

    I write the code for resizing a QRectItem and it works very well.
    For example, to resize my custom QrectItem from the top-right corner, i calculate the new rect in this manner:
    Qt Code:
    1. QRectF new_rect(QPointF(rect().bottomLeft().x(),event->pos().y()),
    2. QPointF(event->pos().x(),boundingRect().bottomLeft().y()));
    To copy to clipboard, switch view to plain text mode 

    When I use the "same" approach for resizing my custom QPixmapItem, it give me problem and resize doesn't work!!

    Qt Code:
    1. QRect new_rect(QPoint(pixmap().rect().bottomLeft().x(),
    2. event->pos().toPoint().y()),
    3. QPoint(event->pos().toPoint().x(),
    4. pixmap().rect().bottomLeft().y()));
    To copy to clipboard, switch view to plain text mode 

    What's wrong???
    Last edited by dreamer; 5th May 2008 at 18:06. Reason: updated contents

  2. #2
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Re: problem resizing rect

    Have someone any idea, dealing with the resizing of a QGraphicsPixmapItem???

    Reading the documentation i find many reasons that could introduce problem during the resize:
    1)When we resize a QGraphicsRectItem, we work on a QrectF that is more accurate to give us the corners coordinate(QGraphicsPixmapItem work with QRect Object)
    2)QGraphicsPixmapItem objects, start drawing its pixmap, starting from the QpointF "offset()", which defines the top-left corner of the pixmap; so i think that if we change the rect of the pixmap, we have to change also the offset() of the current resizing item.

    I make a lot of different version of resizing, but i can't find the solution.
    I find the right resizing method for the bottom side and the bottom right corner(So i think the problem starts when we modify the top-left corner!!!)

    Bottom-side:
    Qt Code:
    1. QRect new_rect(pixmap().rect().topLeft(),
    2. QPoint(pixmap().rect().topRight().x(),event->pos().toPoint().y()));
    3. setPixmap(QPixmap::fromImage(image.scaled(QSize(new_rect.width(),new_rect.height()),Qt::IgnoreAspectRatio,Qt::FastTransformation)));
    To copy to clipboard, switch view to plain text mode 

    Botto-right corner:
    Qt Code:
    1. QRect new_rect(pixmap().rect().topLeft(),QPoint(event->pos().toPoint().x(),
    2. event->pos().toPoint().y()));
    3. setPixmap(QPixmap::fromImage(image.scaled(QSize(new_rect.width(),new_rect.height()),Qt::IgnoreAspectRatio,Qt::FastTransformation)));
    To copy to clipboard, switch view to plain text mode 

    I hope someone will help me.........thanks a lot.

Similar Threads

  1. QGraphicsSvgItem, problem with scaling (invalid bounding rect)
    By Józef Paczenko in forum Qt Programming
    Replies: 3
    Last Post: 8th June 2010, 08:58
  2. Problem on Resizing of QTableView colums ?
    By rajeshs in forum Qt Programming
    Replies: 2
    Last Post: 28th March 2008, 04:03
  3. QTreeWidget, resizing item and widgets problem
    By The Storm in forum Qt Programming
    Replies: 15
    Last Post: 17th March 2008, 21:20
  4. resizing down problem
    By MrGarbage in forum Qt Tools
    Replies: 1
    Last Post: 23rd October 2007, 19:37
  5. QTabWidget - problem with resizing
    By moowy in forum Qt Programming
    Replies: 5
    Last Post: 14th September 2006, 14:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.