Results 1 to 6 of 6

Thread: PyQt5 Button stay pressed after QtWidgets.QFileDialog.getExistingDirectory

  1. #1
    Join Date
    Jan 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default PyQt5 Button stay pressed after QtWidgets.QFileDialog.getExistingDirectory

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,134
    Thanks
    35
    Thanked 1,477 Times in 1,430 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: PyQt5 Button stay pressed after QtWidgets.QFileDialog.getExistingDirectory

    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,
    _

  3. #3
    Join Date
    Jan 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: PyQt5 Button stay pressed after QtWidgets.QFileDialog.getExistingDirectory

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,134
    Thanks
    35
    Thanked 1,477 Times in 1,430 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: PyQt5 Button stay pressed after QtWidgets.QFileDialog.getExistingDirectory

    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,
    _

  5. #5
    Join Date
    Jan 2017
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: PyQt5 Button stay pressed after QtWidgets.QFileDialog.getExistingDirectory

    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?

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,134
    Thanks
    35
    Thanked 1,477 Times in 1,430 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: PyQt5 Button stay pressed after QtWidgets.QFileDialog.getExistingDirectory

    You could check if the "selection" follows the focus, e.g. by calling setFocus() on the window/parent before you show the dialog.

    Cheers,
    _

Similar Threads

  1. QFileDialog::getExistingDirectory crash in linux
    By mqt in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2014, 11:03
  2. Using QFileDialog::getExistingDirectory() to list files too !
    By adaitabehera in forum Qt Programming
    Replies: 0
    Last Post: 14th May 2013, 09:08
  3. strange behavior with QFileDialog::getExistingDirectory
    By cemoktra in forum Qt Programming
    Replies: 1
    Last Post: 2nd May 2013, 14:20
  4. Replies: 0
    Last Post: 31st March 2010, 13:40
  5. Replies: 2
    Last Post: 16th April 2009, 08:51

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.