Results 1 to 6 of 6

Thread: Show grey level value of pixel in Qt when the mouse is over it

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Show grey level value of pixel in Qt when the mouse is over it

    Hi,

    You have to create a class that inherits from QGraphicsItem(in your case QGraphicsPixmapItem). Then redefine the "mouseMoveEvent" method on this class.
    Qt Code:
    1. class MyPixmapItem : public QGraphicsPixmapItem
    2. ...
    3. ...
    4. void mouseMoveEvent()
    5. {
    6. // your code here
    7. }
    To copy to clipboard, switch view to plain text mode 
    Also you will need to connect some kind of SIGNALs and SLOTs from MyPixmapItem to the main window if you want to show the gray value into a QLabel or QSpinBox(just an example).

    When you add the Item in the scene you have to create an object of this class instead of the base class

    This:
    Qt Code:
    1. scene->addPixmap(pix);
    To copy to clipboard, switch view to plain text mode 

    Have to be something like this:
    Qt Code:
    1. MyPixmapItem *item = new MyPixmapItem();
    2. myScene->addItem(item);
    To copy to clipboard, switch view to plain text mode 
    Òscar Llarch i Galán

  2. The following user says thank you to ^NyAw^ for this useful post:

    benz6699 (30th July 2014)

Similar Threads

  1. Replies: 6
    Last Post: 2nd March 2018, 04:39
  2. Get QWidget pixel color below mouse Cursor
    By ^NyAw^ in forum Qt Programming
    Replies: 4
    Last Post: 24th May 2010, 17:17
  3. Replies: 0
    Last Post: 7th May 2010, 22:45
  4. Catching Mouse Events on Top-Level Window
    By andyp in forum Qt Programming
    Replies: 6
    Last Post: 8th September 2009, 10:26
  5. Replies: 2
    Last Post: 21st June 2009, 06:04

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
  •  
Qt is a trademark of The Qt Company.