Results 1 to 2 of 2

Thread: Mouse button repeat not working on QTextEdit inside QGraphicsScene

  1. #1
    Join Date
    May 2009
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Mouse button repeat not working on QTextEdit inside QGraphicsScene

    Greets!

    I'm having some minor difficulty getting a QTextEdit widget to work completely from inside a QGraphicsScene. In general it works okay, but there are two issues:
    * The scroll bar doesn't respond to the mouse button being held down. It only works once per mouse click.
    * Holding down the mouse button and selecting text doesn't cause it to scroll if you move above or below the QTextEdit.

    Here are the mouse event handler functions for my QGraphicsScene:

    Qt Code:
    1. void MapScene::mousePressEvent(QGraphicsSceneMouseEvent * e) {
    2. QGraphicsScene::mousePressEvent(e);
    3. if(e->isAccepted()) return;
    4.  
    5. if(mapBox->map && e->button() == Qt::LeftButton) {
    6. mapBox->SetTile(e);
    7. } else if(mapBox->map && e->button() == Qt::MidButton) {
    8. mapBox->mouse_start_x = e->scenePos().x();
    9. mapBox->mouse_start_y = e->scenePos().y();
    10. } else if(mapBox->map && play && player && e->button() == Qt::RightButton) {
    11. player->clearQueue();
    12. player->queueMoveTo(e->scenePos().x() + mapBox->xo, e->scenePos().y() + mapBox->yo, 500);
    13. }
    14. }
    15.  
    16. void MapScene::mouseMoveEvent(QGraphicsSceneMouseEvent * e) {
    17. QGraphicsScene::mouseMoveEvent(e);
    18. if(e->isAccepted()) return;
    19.  
    20. if(mapBox->map && (e->buttons() & Qt::LeftButton) &&
    21. e->scenePos().x() > 0 && e->scenePos().y() > 0 &&
    22. e->scenePos().x() < this->width() && e->scenePos().y() < this->height()) {
    23. mapBox->SetTile(e);
    24. } else if(mapBox->map && (e->buttons() & Qt::MidButton)) {
    25. emit mapBox->SetXScroll(mapBox->xo - e->scenePos().x() + mapBox->mouse_start_x);
    26. emit mapBox->SetYScroll(mapBox->yo - e->scenePos().y() + mapBox->mouse_start_y);
    27. mapBox->mouse_start_x = e->scenePos().x();
    28. mapBox->mouse_start_y = e->scenePos().y();
    29. }
    30. }
    31.  
    32. void MapScene::mouseReleaseEvent(QGraphicsSceneMouseEvent * e) {
    33. QGraphicsScene::mouseReleaseEvent(e);
    34. if(e->isAccepted()) return;
    35. }
    To copy to clipboard, switch view to plain text mode 

    Any thoughts?

    Thanks!

    Bart

  2. #2
    Join Date
    May 2009
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mouse button repeat not working on QTextEdit inside QGraphicsScene

    bump......

Similar Threads

  1. how to track mouse button inside treeItemClickAction?
    By sudhansu in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 11:07
  2. Mouse move inside control/Widget
    By squidge in forum Newbie
    Replies: 0
    Last Post: 27th September 2009, 16:56

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.