Results 1 to 6 of 6

Thread: QWidgetAction refuse to disappear on trigger()

  1. #1
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWidgetAction refuse to disappear on trigger()

    I have a a QWidgetAction which holds a QWidget composed of a QLineEdit and a QPushButton. Once the user press the button the QWidgetAction call the trigger slot.

    Now I have a QMenu which I activate with exec. The problem is that even though trigger is called (I've connected it to a print function as well to check) the menu won't close.

    Any idea why? I'm at my wits' end.

    (Searching on the net I have found other people with the same problem, but no answers.)

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QWidgetAction refuse to disappear on trigger()

    Have you got a small example program demonstrating the problem that you can post here?

  3. #3
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidgetAction refuse to disappear on trigger()

    Quote Originally Posted by ChrisW67 View Post
    Have you got a small example program demonstrating the problem that you can post here?
    I can't post my code since I it's not small and I can't really separate it into something manageable. So I took Qt Menus example and modified it to show the problem: The relevant code is in the testaction.cpp, testaction.h and in the function contextMenuEvent in the mainwindow.cpp file.

    To see the behavior: compile it, run it, right click anywhere in the program, go into the submenu and try the ok button.

    I really hope you can shed some light on this.
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidgetAction refuse to disappear on trigger()

    Anybody? Anything?

  5. #5
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QWidgetAction refuse to disappear on trigger()

    Hi Dave,

    Don't know whether this will solve the problem with your app but it works on your example. I got the menu to hide when the pushbutton is clicked by doing the following:
    Changed the connect statement in TestAction::createWidget() to this:
    Qt Code:
    1. connect(wgt->btn, SIGNAL(clicked()), this, SIGNAL(triggered()));
    To copy to clipboard, switch view to plain text mode 
    Created "menu" on the heap in MainWindow::contextMenuEvent() and added this connect statement:
    Qt Code:
    1. connect(te, SIGNAL(triggered()), menu, SLOT(hide()));
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to norobro for this useful post:

    dave (23rd May 2010)

  7. #6
    Join Date
    Jan 2006
    Posts
    52
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidgetAction refuse to disappear on trigger()

    It works. but now exec return NULL. Will have to work around it. I really start to wonder if it is a bug int Qt or I'm just not using it right...

Similar Threads

  1. QWidgetAction resize in QMenu
    By stburton in forum Qt Programming
    Replies: 7
    Last Post: 11th January 2018, 14:27
  2. How to make QMenu.exec() return a QWidgetAction
    By gregsan in forum Qt Programming
    Replies: 5
    Last Post: 15th April 2010, 00:04
  3. Replies: 0
    Last Post: 16th March 2010, 12:24
  4. QToolBar, QWidgetAction, QWidget
    By prof.ebral in forum Newbie
    Replies: 3
    Last Post: 18th February 2010, 19:38
  5. QWidgetAction: A QTreeWidget in a QMenu
    By chezifresh in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2009, 03:49

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.