Results 1 to 3 of 3

Thread: Can't move Items in the scene

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Can't move Items in the scene

    Hi guys,

    I have a custom scene, implemented virtual methods:
    Qt Code:
    1. void drawBackground..
    2. void drawForeground..
    3. void mouseMoveEvent ..
    4. void mousePressEvent..
    5. void keyPressEvent ..
    6. void keyReleaseEvent..
    7. void contextMenuEvent..
    To copy to clipboard, switch view to plain text mode 
    Here my view/scene settings
    Qt Code:
    1. m_scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    2. m_scene->setSceneRect(QRectF(QPointF(-180,-90),QPointF(180,90)));
    3. ...
    4. m_view->setCacheMode(QGraphicsView::CacheBackground);
    5. m_view->setOptimizationFlag(QGraphicsView::DontClipPainter);
    6. m_view->setOptimizationFlag(QGraphicsView::DontSavePainterState);
    7. m_view->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    8. m_view->setRenderHints( QPainter::HighQualityAntialiasing);
    9. m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    10. m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    11. m_view->setScene(m_scene);
    12. m_view->setSceneRect(QRectF(QPointF(-180,-90),QPointF(180,90)));
    13. m_view->setBackgroundColor(m_colorMap.value("NODTA"));
    14. m_view->show();
    To copy to clipboard, switch view to plain text mode 
    This is the item I create in the scene/view owner class:
    Qt Code:
    1. item->setPen(QPen(Qt::red));
    2. item->setBrush(QBrush(Qt::red));
    3. item->setFlag(QGraphicsItem::ItemIsMovable);
    4. item->setVisible(true);
    5. m_scene->addItem(item);
    To copy to clipboard, switch view to plain text mode 
    The ellipse is shown, can be selected(if I turn the flag on), but I can't move the item? The question is why?

    Thanks.

    Kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

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

    Default Re: Can't move Items in the scene

    You have to call the base class implementation of mousePressEvent and mouseMoveEvent for the scene.

  3. The following user says thank you to wysota for this useful post:

    maverick_pol (16th May 2008)

  4. #3
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can't move Items in the scene

    Thanks.

    I also found some related topics, useful if someone search the forum and get this thread:
    http://www.qtcentre.org/forum/f-qt-p...tion-8501.html
    http://www.qtcentre.org/forum/f-qt-p...cene-8396.html
    http://www.qtcentre.org/forum/f-qt-p...cene-8396.html

    Kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

Similar Threads

  1. Cann't move movable items on custom graphics view
    By wojtekw in forum Qt Programming
    Replies: 2
    Last Post: 3rd March 2008, 21:30
  2. Creating new scene from a part of an old one
    By maverick_pol in forum Qt Programming
    Replies: 6
    Last Post: 28th November 2007, 18:14
  3. How to update scene after removing items
    By nileshsince1980 in forum Qt Programming
    Replies: 4
    Last Post: 20th September 2007, 09:56
  4. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 17:51
  5. Move multi selected graphics items
    By tebessum in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2007, 20:00

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.