Alexey
Alexey

Reputation: 5978

A slot is called unexpectedly

I have a push button's event connected to a slot as shown below:

myButton = new QPushButton();
myButton->setText("Connect");
myButton->setFocus();
connect(myButton,SIGNAL(released()),this, SLOT(doStuff()));

When I run the program, if I right click on the button "Connect", this calls doStuff() function as expected.

However this slot is also get called when I press and release the space key. This is not desired as I want to connect another slot to space key pressed event. I don't believe I have any other signals connected to "doStuff". Am I missing something? Why does this happen?

Edit: I'd like some other slot to be called on space key released signal. How can I fix this? By removing the focus?

Upvotes: 0

Views: 68

Answers (1)

guneykayim
guneykayim

Reputation: 5250

You can basically remove setFocus() or you need to implement key pressed event. Take a look at these [1], [2] threads.

Upvotes: 3

Related Questions