Results 1 to 4 of 4

Thread: Qt::ItemIgnoresTransformations flag and selectable area

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt::ItemIgnoresTransformations flag and selectable area

    Could you provide a minimal compilable example reproducing the problem?

  2. #2
    Join Date
    Nov 2007
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt::ItemIgnoresTransformations flag and selectable area

    Qt Code:
    1. //////RectItem.h
    2.  
    3. #include <QGraphicsRectItem>
    4. #include <QGraphicsSceneContextMenuEvent>
    5. #include <QStyleOptionGraphicsItem>
    6. #include <QPainter>
    7. #include <QGraphicsScene>
    8. #include <QWidget>
    9. #include <QMenu>
    10.  
    11. class RectItem: public QGraphicsRectItem
    12. {
    13. public:
    14.  
    15. RectItem(QRectF, QGraphicsItem* parent = 0, QGraphicsScene* scene = 0 );
    16. ~RectItem();
    17.  
    18. QRectF boundingRect() const;
    19. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    20. void contextMenuEvent(QGraphicsSceneContextMenuEvent *);
    21. QMenu menu;
    22.  
    23.  
    24. };
    25.  
    26.  
    27.  
    28. /////////////its corresponding cpp file
    29. #include "RectItem.h"
    30.  
    31. RectItem::RectItem(QRectF rect, QGraphicsItem* parent , QGraphicsScene* scene ):
    32. QGraphicsRectItem(rect, parent, scene)
    33. {
    34. menu.addAction("Menu");
    35. }
    36. RectItem::~RectItem()
    37. {}
    38.  
    39. QRectF RectItem::boundingRect() const
    40. {
    41. return QGraphicsRectItem::boundingRect();
    42. }
    43. void RectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    44. {
    45. QGraphicsRectItem::paint(painter, option, widget);
    46. }
    47. void RectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event)
    48. {
    49.  
    50.  
    51. menu.exec(event->screenPos());
    52. }
    To copy to clipboard, switch view to plain text mode 

    Now, the latter code resides in a class, which holds a qgraphicsview in its ui:

    Qt Code:
    1. RectItem * item=new RectItem(QRectF(0,0,50,50));
    2.  
    3.  
    4. scene->addItem(item);
    5. item->setPos(0,0);
    6. item->setFlag(QGraphicsItem::ItemIsMovable, true);
    7. item->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
    8. item->setZValue(1);
    9. item->show();
    10.  
    11. ui.graphicsView->setScene(scene);
    12. ui.graphicsView->setSceneRect(QRectF(-100,-100,200,200));
    13.  
    14. ui.graphicsView->scale(0.2,0.2);
    To copy to clipboard, switch view to plain text mode 

    The context menu works only in a smaller space of the rectangle. The selectable area is not the rectangle seen on the screen.
    Thanks in advance

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt::ItemIgnoresTransformations flag and selectable area

    This indeed could be a bug. Did you check the task-tracker for similar entries?

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
  •  
Qt is a trademark of The Qt Company.