Results 1 to 8 of 8

Thread: Reimplementing mouseMoveEvent function in QGraphicsProxyWidget does not work.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2013
    Posts
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Reimplementing mouseMoveEvent function in QGraphicsProxyWidget does not work.

    Hello,
    I am doing a program which allow to put, move and resize QWidget (QSlider, QPushButton, QDial...) inside a workspace. This workspace is a QGraphicView. I use a QGraphicsProxyWidget with a QGraphicsRectItem as parent to be able to move it easily and I give my widget to ProxyWidget which is inherited from QGraphicsProxyWidget.
    Then, to resize my widget, I try to reimplement the functions mousePressEvent() (which works well) and mouseMoveEvent() but it does not work.

    I tried to do setMouseTracking(true) on my widget, but nothing.

    Here my code:

    Qt Code:
    1. rectItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
    2. scene->addItem(rectItem);
    3.  
    4. QDial *label = new QDial();
    5. label->setMouseTracking(true);
    6. ProxyWidget *proxyWidget = new ProxyWidget(rectItem);
    7. proxyWidget->setWidget(label);
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void ProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *e)
    2. {
    3. if (this->isMovable)
    4. e->ignore(); //[1]
    5. else
    6. e->accept();
    7. }
    To copy to clipboard, switch view to plain text mode 

    In ProxyWidget I have just reimplemented mousePressEvent() and mouseMoveEvent().

    Any idea?

    EDIT: If I change e->ignore() by e->accept() mouseMoveEvent() works. But I cannot move my widget anymore because my widget get the focus, for exemple for a QPushButton, the button is pushed.
    Last edited by Binpix; 30th August 2013 at 02:26.

Similar Threads

  1. Replies: 3
    Last Post: 1st May 2013, 20:44
  2. reimplementing mouseMoveEvent of QGraphicsItem
    By MTW in forum Qt Programming
    Replies: 1
    Last Post: 18th December 2010, 17:45
  3. Replies: 1
    Last Post: 11th May 2010, 14:29
  4. problem reimplementing mouseMoveEvent
    By jhowland in forum Qt Programming
    Replies: 2
    Last Post: 6th April 2010, 20:18
  5. qSort doesn't work with member function
    By ber_44 in forum Qt Programming
    Replies: 10
    Last Post: 2nd June 2007, 12:00

Tags for this Thread

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.