Results 1 to 15 of 15

Thread: Detect Button Press / Release in toolbar

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Detect Button Press / Release in toolbar

    Thanks Anda,

    I used the event filter because I was unable to figure out how to use these signals of the button on a toolbar.

    I can use the signals from a normal push button but I can't understand how to get the same signals from the toolbar buttons.

    Is there any example of using the QAbstractButton in this way or a similar way?

    I am new to this so sorry if it is obvious....

    Thanks Again,
    Louis

  2. #2
    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: Detect Button Press / Release in toolbar

    Quote Originally Posted by irish_guy@hotmail.com View Post
    I can use the signals from a normal push button but I can't understand how to get the same signals from the toolbar buttons.
    There is no difference. The signal/slot mechanism works the same way for all QObject subclasses

    With SIGNAL/SLOT macros:
    Qt Code:
    1. connect(pointerToToolButton, SIGNAL(pressed()), pointerToReceiver, SLOT(someSlotNameHandlingPress()));
    To copy to clipboard, switch view to plain text mode 
    The circumstance that the button is on a toolbar doesn't change anything, connect() doesn't even care that the sender is a QWidget derived class.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2014
    Posts
    8
    Thanks
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Detect Button Press / Release in toolbar

    Thanks again & Almost there I think...

    When I try to connect the signals and slots... I get a run time message that there is No such Signal QAction:ressed()

    connect(ui->actionZoom_In, SIGNAL(pressed()), this, SLOT(MousePress()));

    QObject::connect: No such signal QAction:ressed() in ../CameraControlGUI/mainwindow.cpp:66
    QObject::connect: (sender name: 'actionZoom_In')
    QObject::connect: (receiver name: 'MainWindow')

    When I connect to the 'triggered signal'

    connect(ui->actionZoom_In, SIGNAL(triggered()), this, SLOT(MousePress()));

    it works fine but I really need pressed and released...

    Regards
    Louis

  4. #4
    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: Detect Button Press / Release in toolbar

    Ah, yes, I should have written QToolButton, not QAction.

    Oh, wait, I did.

    Cheers,
    _

Similar Threads

  1. how to capture the F1 - key press/release event
    By sajis997 in forum Qt Quick
    Replies: 1
    Last Post: 6th January 2015, 22:25
  2. Mouse Press/Release Events
    By Vivek1982 in forum Newbie
    Replies: 27
    Last Post: 22nd August 2014, 13:17
  3. Want to detect keyboard key press other than modifier keys
    By Rajesh.Rathod in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2013, 07:19
  4. Replies: 6
    Last Post: 21st August 2010, 21:09
  5. 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

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.