Results 1 to 10 of 10

Thread: implementing drawForeGround

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2007
    Posts
    9
    Thanks
    3

    Default Re: implementing drawForeGround

    Thanx, I have got I working I understand everything now, except one thing: what does the next sentence do:

    Qt Code:
    1. QGraphicsItem::mousePressEvent(event); //in the paint method
    To copy to clipboard, switch view to plain text mode 

    Thanx again to all of you

  2. #2
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 21 Times in 21 Posts

    Default Re: implementing drawForeGround

    This sentence calls the default implementation of this method.
    Really useful, you don't have to handle all the possible events : just reimplement the one you are interested in, and let the default code handle the others ;-)

  3. #3
    Join Date
    Apr 2007
    Posts
    9
    Thanks
    3

    Default Re: implementing drawForeGround

    Everything works very fine but now I have another (new) problem:

    When clicked on a rectangle, the main program should be able to know where there has been clicked. Is it possible to send a signal to the Scene from within eg: Item's mouseEvent???

  4. #4
    Join Date
    Jan 2006
    Location
    Paris, France
    Posts
    227
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 21 Times in 21 Posts

    Default Re: implementing drawForeGround

    Well, items are not QObject, so you can't use signals / slots, unless you made a subclass which inherit QObject

    You can always have access to the scene pointer with scene() (only if you stored your item in the scene).

    QGraphicsMouseEvent has useful methods to obtain position : pos() -> item coordinates, scenePos() -> scene coordinates.

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

    Default Re: implementing drawForeGround

    If an item ignores an event, it will propagate to the scene and can be handled there. I don't know if it is exactly what you want... Maybe it'll be easier to call some method of the scene in item's mouse event handler instead?

Similar Threads

  1. Implementing scale-invariant QGraphicsItems
    By spud in forum Qt Programming
    Replies: 12
    Last Post: 13th January 2012, 06:18
  2. Implementing MenuBar AutoHide function
    By viking in forum Qt Programming
    Replies: 31
    Last Post: 1st April 2011, 21:17
  3. Implementing IME using QT
    By pmohod in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2007, 13:22
  4. Implementing Resize funtionality
    By PiXeL16 in forum Qt Programming
    Replies: 2
    Last Post: 15th February 2007, 00:12
  5. Making 3D controls in QT, implementing a game loop in QT
    By smurrish in forum Qt Programming
    Replies: 10
    Last Post: 26th April 2006, 05:37

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.