Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

WidgetMenuExtended removeItem

2006-12-27
2013-04-08
  • Calling removeItem more than twice causes the application to crash.
    Using Version 2.0.0 RC1. I want to remove several items from a context menu by iterating through it like:

    for ( int i = start; i < end; ++i )
        contextMenu->removeItem(i);

     
    • Conrado PLG
      Conrado PLG
      2006-12-27

      You should remove from end to start. removeItem is based on the menu position, when you remove an item, all subsequent items change positions!

      for ( int i = end - 1; i >= start; --i )
        contextMenu->removeItem(i);

      or (a little bit less intuitive):

      for ( int i = start; i < end; ++i )
        contextMenu->removeItem(start);