Results 1 to 20 of 28

Thread: Mouse Press/Release Events

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mouse Press/Release Events

    Quote Originally Posted by Vivek1982 View Post
    suggest how it can be done in other ways.
    You could create a subclass if QGraphicsView and implement the mouse event handler methods. Then promote the GraphicsView in designer to that class.

    Cheers,
    _

  2. #2
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mouse Press/Release Events

    ok. will create my Ui form in mainwindow form. But declaration of GraphicsView to be done in sub class mouseevent.cpp and mouseevent.h, which is not having the Ui form. Im confused by seeing Scribblearea example. Here positions are collected from scribblearea.cpp and same is brought on mainwindow of class. Let me give a try. or i will post the code. based on comments i will try to do it. Thats wat i can do now

  3. #3
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mouse Press/Release Events

    Dear All,

    Finally I got mouse press/release event on Graphicscene by eventfilter. Im getting the co-ordinates by mouse events. For the same positions to draw lines I have made paint event,but calling paint event from switch (event filter) is not possible. Any methods to call the paint event.

    Thanks in advance

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Mouse Press/Release Events

    calling paint event from switch (event filter) is not possible
    Store the mouse coordinates and use them later in paintEvent.

  5. #5
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mouse Press/Release Events

    ya.. Im able to get mouse positions on QpointF .. but in event filter points are stored .. by releasing the mouse button it has to draw line.. in header file i have void PaintEvent (QPaintEvent *event ).
    but it has to be called after release button is left...
    In header.cpp i have void MainWindow::PaintEvent then following by painter pen then draw line.. the positions are from event filter...

  6. #6
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Mouse Press/Release Events

    by releasing the mouse button it has to draw line
    Call "update()" after storing the coordinates and releasing the mouse button.

  7. #7
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mouse Press/Release Events

    Im not able to access the values of Mouse press/release events from Case events to and not able to carry the same values to void MainWindow:aintEvent(QPaintEvent *e).
    To draw the line, I have called update() function at Mouse release case in event filter.Im getting all junk or Hexa values in qDeug...

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mouse Press/Release Events

    And you want us to guess what is wrong?

  9. #9
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mouse Press/Release Events

    Sorry. Im not able to point it out. In case QEvent::GraphicsSceneMouseRelease: Im getting the ScenePos, but when it is called in void MainWindow:aintEvent(QPaintEvent *e) same data/value is not coming. Or im getting the address of it or wat. Im feeling wrong somewhere, but finding it hard to correct it


    Added after 51 minutes:


    Yes I have stored in Case events in int x,y,x1,y1 for respective points. while calling same x,y,x1,y1 im not getting it when draw line or void MainWindow:aintEvent(QPaintEvent *e)
    Last edited by Vivek1982; 12th August 2014 at 12:35.

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mouse Press/Release Events

    This is pointless.

    Unless you actually show the code where you store and retrieve the values, there is nothing anyone else can do.

    Cheers,
    _

  11. #11
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mouse Press/Release Events

    Hi..
    I have attached the code in a zip file. I have to store the co-ordinates but mouse points are not getting stored in this variable for paint on scene.
    Last edited by Vivek1982; 22nd August 2014 at 13:15.

  12. #12
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Mouse Press/Release Events

    If you want to have access to the values from a different method, you should store them in the member variables, not in local variables.

    Cheers,
    _

  13. #13
    Join Date
    Sep 2013
    Posts
    107
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Mouse Press/Release Events

    ok.. plz can i get link supporting on member varaible or how it can be used in my condition to store data and process while painting

  14. #14
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Mouse Press/Release Events

    can i get link supporting on member varaible
    http://www.cplusplus.com/doc/tutorial/classes/

  15. The following user says thank you to stampede for this useful post:

    Vivek1982 (27th August 2014)

Similar Threads

  1. Replies: 3
    Last Post: 8th October 2011, 09:46
  2. Replies: 6
    Last Post: 27th January 2011, 17:06
  3. How catch key press and key release for entire application
    By hubbobubbo in forum Qt Programming
    Replies: 4
    Last Post: 1st June 2010, 20:53
  4. Problem in Mouse Press Events & Vectors
    By dheeraj in forum Qt Programming
    Replies: 2
    Last Post: 5th July 2008, 18:08
  5. Replies: 2
    Last Post: 2nd April 2008, 14:19

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.