Results 1 to 2 of 2

Thread: How to receive notifications when a QList has been changed?

  1. #1
    Join Date
    May 2011
    Posts
    46
    Thanks
    5

    Default How to receive notifications when a QList has been changed?

    Consider this code:
    Qt Code:
    1. bar.actions().append(new QAction("Hello World"));
    To copy to clipboard, switch view to plain text mode 

    QMenuBar returns a QList of QAction pointer, after I appended a new action, how does QMenuBar be notified on the change, so that it can update the UI accordingly?

    I also tried to create a class that inherits from QList and I found no way to be notified when the list is changed.

    Thanks in advance.

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

    Default Re: How to receive notifications when a QList has been changed?

    You're going about it backwards. You add an action to QMenuBar or QMenu and then get a new QList of QActions.

    From the docs:
    A menu consists of a list of action items. Actions are added with the addAction(), addActions() and insertAction() functions. An action is represented vertically and rendered by QStyle. In addition, actions can have a text label, an optional icon drawn on the very left side, and shortcut key sequence such as "Ctrl+X".

    The existing actions held by a menu can be found with actions().

Similar Threads

  1. Replies: 8
    Last Post: 5th April 2011, 10:19
  2. Replies: 4
    Last Post: 20th August 2010, 13:54
  3. Subscribe to ALL Notifications
    By otternase in forum Qt Programming
    Replies: 0
    Last Post: 6th June 2010, 13:27
  4. QDBus and org.freedesktop.Notifications.Notify
    By TheOneRing in forum Qt Programming
    Replies: 12
    Last Post: 23rd November 2009, 10:34
  5. Notifications of exceptions in debug output
    By piotr.dobrogost in forum Qt Programming
    Replies: 0
    Last Post: 21st September 2009, 20:21

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.