Results 1 to 8 of 8

Thread: Question about the MouseMoveEvent of qtdemo's TextButton

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Posts
    5
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: Question about the MouseMoveEvent of qtdemo's TextButton

    Qt Code:
    1. void TextButton::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    2. {
    3. qDebug() << pos();
    4. QGraphicsItem::mouseMoveEvent(event);
    5. }
    To copy to clipboard, switch view to plain text mode 
    Only to add the pos output. and Nothing modited to the qtdemo source besides added the ItemIsMovoble flag;

    the moving graber is in scene coordinates
    Last edited by high_flyer; 22nd February 2011 at 13:23. Reason: code tags

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Question about the MouseMoveEvent of qtdemo's TextButton

    But where is the code that sets the position in your code?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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

    yzdying (23rd February 2011)

  4. #3
    Join Date
    Sep 2010
    Posts
    5
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: Question about the MouseMoveEvent of qtdemo's TextButton

    Thanks again!
    Qt Code:
    1. //TextButton.cpp
    2. void TextButton::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    3. {
    4. qDebug() << pos();
    5. QGraphicsItem::mouseMoveEvent(event);
    6. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. menumanager.cpp
    2. void MenuManager::createMenu(const QDomElement &category, BUTTON_TYPE type)
    3. {
    4. .........
    5.  
    6. // create normal menu button
    7. QString label = currentNode.toElement().attribute("name");
    8. item = new TextButton(label, TextButton::LEFT, type, this->window->scene, this->window->mainSceneRoot);
    9. currentNode = currentNode.nextSibling();
    10.  
    11. item->setFlags(QGraphicsItem::ItemIsMovable); ///this line is my added
    12.  
    13. .........
    14. }
    To copy to clipboard, switch view to plain text mode 


    Only modified two places in the source of qtdemo.
    But course that the moving item jump from (59, 233) to (0, 1) in the procedure of qtdemo.

Similar Threads

  1. QtDemo
    By Raymond in forum Qt Programming
    Replies: 7
    Last Post: 22nd April 2010, 11:52
  2. qtdemo question
    By link in forum Qt Programming
    Replies: 4
    Last Post: 24th February 2009, 17:04
  3. qtdemo 4.4 looks like this on my machine!
    By magland in forum General Discussion
    Replies: 1
    Last Post: 25th May 2008, 07:55
  4. QGraphicsScene::mouseMoveEvent Question
    By harakiri in forum Qt Programming
    Replies: 3
    Last Post: 3rd March 2008, 14:54
  5. How to get qtdemo with reasonable speed?
    By ponto in forum General Discussion
    Replies: 8
    Last Post: 31st May 2006, 10:25

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.