From 535200118bf2a59fcb6f8fcda4eea53851e85eeb Mon Sep 17 00:00:00 2001 From: laserpants Date: Sun, 24 Apr 2016 14:38:58 +0300 Subject: [PATCH] keep list of pointers to MenuItems in Menu class --- components/menu.cpp | 1 + components/menu.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/components/menu.cpp b/components/menu.cpp index c978848..7f9bd86 100644 --- a/components/menu.cpp +++ b/components/menu.cpp @@ -42,6 +42,7 @@ Menu::~Menu() void Menu::addMenuItem(MenuItem *item) { + _items.push_back(item); layout()->addWidget(item); } diff --git a/components/menu.h b/components/menu.h index 779b14b..727e965 100644 --- a/components/menu.h +++ b/components/menu.h @@ -25,8 +25,13 @@ public: void addMenuItem(MenuItem *item); void addMenuItem(const QString &text); + inline int itemCount() const { return _items.count(); } + protected: void paintEvent(QPaintEvent *event); + +private: + QList _items; }; #endif // MENU_H