Qt World Summit: Submit your Presentation

Execute different commands on press and release of button

  • Hi,
    I am an artist and not a programmer. I am creating an interface in QT which connects with an application and executes some commands in there. So far I have figured out how to execute basic commands and python commands, I wish to know how can I have two different commands for press and release of a button in an ui in QT designer.

    So on press the button runs a command in the application
    and on release of the same button another command.

    Sorry if this is too basic, I did google and try to find an answer but am a bit stuck.

    Thanks a lot.

  • @mnkyshield Look at all members of QPushButton and you will see that there is a signal for pressed and one for release, so connect those to your methods.

  • They are two different 'signals' emitted by the QPushButton class
    Connect(pushButton, SIGNAL(pressed()), this, SLOT(pushButtonPressSlot()))
    Connect(pushButton, SIGNAL(released()), this, SLOT(pushButtonReleaseSlot()))

  • I have found a hacky way of making it work, might have to learn python and QT properly at some time, for now thanks guys :D

Log in to reply