Results 1 to 3 of 3

Thread: QToolButton How to close/dismiss the menu?

  1. #1
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default QToolButton How to close/dismiss the menu?

    I'm having some trouble dismissing the QToolBar DropDown Menu.

    I uploaded a little gif to help explain.
    https://ibb.co/8X8VCS5

    I have 2 QToolButtons. One has a dope down menu, the other is just a clicker.
    The pulldown, when clicked on, will search for any Cameras and populate them in the menu. If it isn't clicked on, it doesn't update the menu. It just has 'default'.
    The other Qtoolbutton is the little camera icon next to it. In the attached gif link, it's the button that turns red. This button will only activate if a camera is selected from the pull-down. So i need to trigger the menu, and have it load all the cameras, then select a camera, then push the camera icon.

    What it's doing:

    I am programmatically clicking/activating these two buttons with a third button called 'Active Viewer Setup.'
    using the code below, i open the menu, forcing it to populate. (Camera01 gets added)
    Qt Code:
    1. cameraSelectionButton.showMenu()
    To copy to clipboard, switch view to plain text mode 

    Then I select Camera01 from the menu if it matches my text.
    Qt Code:
    1. [camera.trigger() for camera in cameraSelectionButton.menu().actions() if camera.text() == 'Camera01']
    To copy to clipboard, switch view to plain text mode 

    Then the Camera Icon button gets clicked to activate. (turns red)
    Qt Code:
    1. cameraActivateButton.click()
    To copy to clipboard, switch view to plain text mode 

    The Problem:

    The Menu doesn't close/dismiss. If you take a look at the gif, You'll see everything gets clicked, and activates, but it doesn't show because the menu is still open. I have to do a second click, which closes the menu and then things update. When I omit the code for showMenu, and click it myself using the mouse, everything works. This is how I know its the menu not closing that is causing the issue.

    Is there a way to close this menu ? Any advice/alternative ways of doing this?

    Thanks!

    Nick

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QToolButton How to close/dismiss the menu?

    It is probably enough to just call "close()" on the menu.

    Cheers,
    _

  3. #3
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QToolButton How to close/dismiss the menu?

    Thanks for your reply.

    I tried close() earlier while looking for a solution. Unfortunately, it seems like the button, in it's open state won't allow anything else to update. (graphics wise).
    Is there a way to find the 'Slot', or trigger the 'Signal' that it sends without opening the menu? It sends a "fetch all cameras in scene" , but I don't know the name.

    Thanks,

    Nick

Similar Threads

  1. qtoolbutton and not visible popup menu
    By _Jack_ in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2019, 00:15
  2. Replies: 2
    Last Post: 11th May 2012, 11:38
  3. qtoolbutton popup menu
    By anoar in forum Qt Programming
    Replies: 1
    Last Post: 6th December 2008, 06:20
  4. Replies: 12
    Last Post: 21st November 2008, 05:42
  5. QToolButton icon not updated in overflow menu
    By pabakertx in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2007, 14:48

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.