Results 1 to 7 of 7

Thread: QPushButton:: Handle right mouse button events. Easyway?

  1. #1
    Join Date
    Nov 2006
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QPushButton:: Handle right mouse button events. Easyway?

    Got a QPushButton widget which needs to trap the "right click", "right release" mouse events.

    As far as I can see QPushButton::mousePressEvent(....) needs modifiying to do this.

    Is there a simple way to do this without coding another QPushButton class.

    Cheers

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

    Default Re: QPushButton:: Handle right mouse button events. Easyway?

    What do you want to do upon right click?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QPushButton:: Handle right mouse button events. Easyway?

    Quote Originally Posted by Harvey West View Post
    Got a QPushButton widget which needs to trap the "right click", "right release" mouse events.

    As far as I can see QPushButton::mousePressEvent(....) needs modifiying to do this.

    Is there a simple way to do this without coding another QPushButton class.
    What is the task? What do you intend to do with the right mouse button press and release information?
    This is just a wild guess, but are you maybe showing a menu of some kind? If so, maybe a QToolButton with it's built-in menu capabilities would be sufficient..?
    J-P Nurmi

  4. #4
    Join Date
    Nov 2006
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPushButton:: Handle right mouse button events. Easyway?

    Button needs to show text. Think Qtoolbar does not do this. Uses icons instead.
    The event is used to launch a modeless Dialog ( with Table )
    Action required is similar to the left mouse clicked button event. i.e. button animated down/up.

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

    Default Re: QPushButton:: Handle right mouse button events. Easyway?

    If you don't add an icon to QAction, it will show up as text in the toolbar.

    BTW. If the dialog has a "context menu like" functions, you can react on customContextMenuRequested ( const QPoint & pos ) signal (just remember to switch the context menu property of the button so that this signal gets emitted).

  6. #6
    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: QPushButton:: Handle right mouse button events. Easyway?

    Also if u want to display text along with icon in the toolbar, you can use
    void QToolBar::setToolButtonStyle ( Qt::ToolButtonStyle toolButtonStyle )

  7. #7
    Join Date
    Nov 2006
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPushButton:: Handle right mouse button events. Easyway?

    QToolBar looking good for what i want. I'll give this a go. Cheers

Similar Threads

  1. Mouse Over event on button
    By vishal.chauhan in forum Qt Programming
    Replies: 9
    Last Post: 10th January 2007, 05:03
  2. Re-implement mouse events of QTextEdit
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2006, 16:55
  3. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 06:13
  4. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25
  5. QPushButton mouse events
    By Twey in forum Newbie
    Replies: 5
    Last Post: 15th January 2006, 16:41

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.