Results 1 to 2 of 2

Thread: QGraphicsView mousePressEvent -- how to setup the signal and slots?

  1. #1
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question QGraphicsView mousePressEvent -- how to setup the signal and slots?

    Hi, all:

    I created a class "CqtImageView" which inherits from QGraphicsView, in which I overwrite mousePressEvent


    Qt Code:
    1. class CqtImageView : public QGraphicsView
    2. {
    3. ...
    4. void mousePressEvent(QMouseEvent *event);
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 


    One "CqtImageView" object is further created in the "Ui" of my main class,

    Qt Code:
    1. class CMyMain : public QMainWindow
    2. {
    3. ...
    4. Ui::mymainClass ui;
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 
    this ui contains a "CqtImageView" widget.


    I would like to count the mouse pressed times over the CqtImageView in CMyMain class.
    Therefore, I may need an signal-slot to inform CMyMain when mousePressEvent happens.

    How to?

    Cheers
    JIA
    Welcome to Vision Open
    http://www.visionopen.com

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView mousePressEvent -- how to setup the signal and slots?

    Therefore, I may need an signal-slot to inform CMyMain when mousePressEvent happens.
    You are right there..
    from the CqtImageView ::mousePressEvent emit a custom signal
    emit viewPressed(); you can also have a internal count and may have a signal like
    void viewPressed(int /*count*/);

    Then in main window I guess you know how to connect signal-slots , right ?

Similar Threads

  1. Signal and Slots
    By waynew in forum Newbie
    Replies: 3
    Last Post: 20th November 2009, 03:50
  2. signal and slots
    By vermarajeev in forum Qt Programming
    Replies: 4
    Last Post: 16th October 2007, 08:31
  3. Signal and slots
    By villy in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2007, 10:10
  4. signal/slots across threads in Qt4
    By Ambiorix in forum Qt Programming
    Replies: 7
    Last Post: 31st July 2006, 08:05
  5. Problem with Signal and Slots
    By Kapil in forum Installation and Deployment
    Replies: 2
    Last Post: 10th February 2006, 08:51

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.