[SOLVED] Push Button Issue



  • Hi,

    I have created a pushButton in Qt Designer and two signals-slots connections like the following:

    Sender Signal Receiver Slot
    pushButtonStart pressed MyClass StartPressed()
    pushButtonStop released MyClass StartReleased()

    However I can see in a log file that whenever I click the pushButton, both signals get called.
    Do I need to create the pushButton with some extra option that allows the pressed/released behaviour to work?

    Thanks
    M



  • I've just discovered what the problem is.

    pushButton pressed/released actually refer to the mouse!
    Is there a way then to define what I need, which is to assign one behavior to when the button is pressed and a different behavior to when the button is released?

    Many Thanks


  • Lifetime Qt Champion

    Hi,

    Are you thinking about something like toggling ?



  • yes exactly,
    If I link the pushButton to a Radio button (this would show the user the status of the button better) then the SLOT for clicking the button is toggle().
    Can I then read a TRUE/FALSE status of the radio button from here?

    Thanks



  • for a QPushButton use setCheckable to make it toggling and connect it toggled ( bool checked ) signal to fetch its status

    click= press + release cycle

    toggling happens every click :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.