PDA

View Full Version : PyQt5 Button stay pressed after QtWidgets.QFileDialog.getExistingDirectory



imbie
24th January 2017, 08:44
Hey, I'm having an issue with the Qt Interface in my Python 3.5/PyQt5 application.

I'm calling the following function QtWidgets.QFileDialog.getExistingDirectory(dialog, "Select Directory")) via this button in the code self.uib_setdirectory.clicked.connect(self.setdire ctory).

Everything works well, however the issue is that the button stays pressed down after the QFileDialog is done.
Only when I press another button in the Interface the highlighting ends.

Am I missing a specific function call to disable the selection after the file Dialog? :confused:

anda_skoa
24th January 2017, 09:15
Maybe you accidentally activated the "checkable" property of the button?

Does this also happen if you do not show the file dialog in the method connected to clicked()?

Cheers,
_

imbie
24th January 2017, 09:58
Hey, I checked via QtDesigner and the checkable method is not activated.

What currently happens when I launch the Interface also via QtDesigner is that one Button is already highlighted on Application Start, as if the mouse already hovers over it.
It stays highlighted as long until another button in the Interface is pressed. Maybe it is just a property not checked correctly in QtDesigner itself?

anda_skoa
24th January 2017, 13:39
I think that is just the "default" button, i.e. the button that would get activated if Return/Enter is hit.

Ok, so the checkable property is not set.

So what happens when you comment out the line that shows the file dialog?
Does the button still get stuck?

Cheers,
_

imbie
24th January 2017, 14:37
Ok so I think the "selection" design is quite obvious in the stylesheet I'm asked to write the appliaction in.

And the problem is that the button is staying "selected" until I press another button, also when I'm not hovering with the mouse over it.
So from what I can see the issue is not the"pressed" but the hover/selected state.

I would expect the selected state to not last when I am not hovering over the button, clicking on the background etc.
But it gets only changed when I selected another button ui element. Is there anyway to change that behaviour?

anda_skoa
25th January 2017, 09:47
You could check if the "selection" follows the focus, e.g. by calling setFocus() on the window/parent before you show the dialog.

Cheers,
_