Results 1 to 4 of 4

Thread: Can't disable a QAction in QMenu

  1. #1
    Join Date
    Oct 2007
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question Can't disable a QAction in QMenu

    Hi,

    I have few QActions added to a QMenu:
    ui->menuView->addAction( pAction1 );
    ui->menuView->addAction( pAction2 );
    ui->menuView->addAction( pAction3 );

    My problem is that I can't disable a particular QAction:
    pAction2->setDiasbled( true ); // doesn't do anything

    In the documentation it is written: "An action will be disabled when all widgets to which it is added (with QWidget::addAction()) are disabled or not visible."
    So why it doesn't work makes sense, but it is not what I want.

    How can I do it?

    Thanks.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can't disable a QAction in QMenu

    What error are you getting ?
    pAction2->setDiasbled( true );
    is that typo here ? it should be setDisabled.... spelling mistake

  3. #3
    Join Date
    Oct 2007
    Posts
    22
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Can't disable a QAction in QMenu

    Sorry, spelling mistake. Compiling is ok, no output message in the console, nothing happens : the QAction's text is not grayed and can still be triggered.

  4. #4
    Join Date
    Sep 2009
    Location
    Finland
    Posts
    63
    Thanks
    1
    Thanked 22 Times in 19 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Can't disable a QAction in QMenu

    I use QAction::setEnabled without problems (disabled is inline method for !enabled), are you sure that the piece of code that disables pAction2 is executed? Add qDebug in front of the line and see whether that trace is printed.

Similar Threads

  1. Why QAction inside Qmenu doesn't display Icon ?
    By jpujolf in forum Qt Programming
    Replies: 8
    Last Post: 21st December 2009, 12:51
  2. how to add QMenu or QAction inside QDesigner
    By eric_vi in forum Qt Tools
    Replies: 1
    Last Post: 2nd August 2009, 16:48
  3. QAction text color (QMenu)
    By StefanK in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2009, 15:14
  4. QPushButton QMenu QAction
    By hgedek in forum Newbie
    Replies: 2
    Last Post: 1st November 2007, 12:29
  5. Replies: 2
    Last Post: 23rd February 2006, 16:38

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.