Results 1 to 4 of 4

Thread: Facing problem with Q3Canvas

Hybrid View

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

    Default Re: Facing problem with Q3Canvas

    You should map the scrollarea's coordinates to the viewport coordinates either by adding values of the scrollbars or by using mapFromParent.

    Qt Code:
    1. m_zoomStartPoint = (inverseWorldMatrix()).map(mapFromParent(a_e->pos()));
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Facing problem with Q3Canvas

    Hi ,

    Still it is not working.

    Qt Code:
    1. void
    2. DiagramView :: contentsMouseMoveEvent(QMouseEvent* a_e)
    3. {
    4. if(cursor().shape() == Qt::CrossCursor) {
    5. //QPoint myPoint = viewportToContents(a_e->pos());
    6. m_zoomEndPoint = (inverseWorldMatrix()).map(mapFromParent(a_e->pos()));
    7. int width = m_zoomEndPoint.x()-m_zoomStartPoint.x();
    8. int height = m_zoomEndPoint.y()-m_zoomStartPoint.y();
    9. if((width>0)&&(height>0)) {
    10. if(!m_zoomRegionRect) {
    11. //! canvas item do not exist
    12. m_zoomRegionRect = new Q3CanvasRectangle(m_zoomStartPoint.x(),
    13. m_zoomStartPoint.y(),
    14. width, height, canvas());
    15. m_zoomRegionRect->setBrush(Qt::DiagCrossPattern);
    16. m_zoomRegionRect->setPen(QPen(Qt::darkGreen,
    17. 2, Qt::DashDotDotLine));
    18. m_zoomRegionRect->setZ(100);
    19. m_zoomRegionRect->show();
    20. } else {
    21. m_zoomRegionRect->setSize(width, height);
    22. canvas()->setChanged(m_zoomRegionRect->boundingRect());
    23. }
    24. canvas()->update();
    25. }
    26. return;
    27. }
    28. }
    29. void
    30. DiagramView :: contentsMousePressEvent(QMouseEvent* a_e)
    31. {
    32. m_zoomStartPoint = (inverseWorldMatrix()).map(mapFromParent(a_e->pos()));
    33. }
    34.  
    35. void
    36. DiagramView :: contentsMouseReleaseEvent(QMouseEvent* )
    37. {
    38. if(cursor().shape() == Qt::CrossCursor) {
    39. if(m_zoomRegionRect) {
    40. m_zoomRegionRect->hide();
    41. canvas()->update();
    42. delete m_zoomRegionRect;
    43. m_zoomRegionRect = 0;
    44. m_zoomStartFlag = true;
    45. emit ZoomToRegion(m_zoomStartPoint, m_zoomEndPoint);
    46. canvas()->update();
    47. }
    48. return;
    49. }
    50. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Facing problem with Q3Canvas

    hi.

    are u deriving the class DiagramView from Q3CanvasView...

    For me something like this works pretty fine...

    Qt Code:
    1. void CanvasMouse::contentsMousePressEvent(QMouseEvent* e)
    2. {
    3. if(e->button() == Qt::LeftButton)
    4. {
    5. QPoint pPress = inverseWorldMatrix().map(e->pos());
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

    though it seems a crude method but try something like this that try to call the mouse events in the class where u have created the canvas... where u have set its size and its view... it might help...

    Kapil
    All you have to decide is what to do with the time that is given to you

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  2. Replies: 3
    Last Post: 2nd July 2008, 03:00
  3. i am facing a problem with QTextEdit!!!
    By mismael85 in forum Qt Programming
    Replies: 9
    Last Post: 10th March 2008, 18:06
  4. Facing problem with tool bar icons
    By jnana in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 08:37
  5. Facing problem with qt-4.1 designer
    By jnana in forum Qt Tools
    Replies: 4
    Last Post: 8th March 2006, 18:16

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.