Results 1 to 4 of 4

Thread: Enabling/Disabling QActions in QMenus

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Enabling/Disabling QActions in QMenus

    I'm converting Qt3 code to Qt4 on Linux, and am having a weird problem. I create QActions and add them to a menu using:

    RemoveAllAction = new QAction(this);
    RemoveAllAction->setText(tr("Re&set All"));
    RemoveAllAction->setToolTip(tr("Reset everything"));
    RemoveAllAction->setShortcut(QKeySequence(tr( "Alt+S" )));
    connect( RemoveAllAction, SIGNAL(triggered()), this, SLOT(RemoveAllAction_activated()));
    ...
    optionsMenu = new QMenu(this);
    clearMenu = new QMenu(this);
    clearMenu->addAction(RemoveAllAction);
    RemoveAllAction->setEnabled(false);
    clearMenu->setTitle("Clear");
    optionsMenu->addMenu(clearMenu);
    ...
    menuBar()->addMenu(optionsMenu);

    When I try to enable the RemoveAllAction QAction later using RemoveAllAction->setEnabled(true), I get a segmentation fault! If I comment out the line that does the disable, the code runs OK. I have several other actions that act the same way I initially thought it might have something to do with the fact that the QAction is in a sub-menu, but since it works OK when I comment out the initial disable (or change the second setEnabled to false). I don't think so. I've spent many hours on this already ! Any ideas?
    Last edited by rshabsin; 15th February 2006 at 21:17.

Similar Threads

  1. Problems with QActions and Pixmaps
    By ToddAtWSU in forum Qt Programming
    Replies: 8
    Last Post: 11th April 2007, 21:53

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
  •  
Qt is a trademark of The Qt Company.