on par with desktop components

add item and clear menu
This commit is contained in:
Marco Martin 2011-12-20 15:36:26 +01:00
parent 4df3869dc6
commit bb0bb5bb4e
2 changed files with 15 additions and 0 deletions

View File

@ -73,6 +73,19 @@ void QMenuProxy::setVisualParent(QDeclarativeItem *parent)
emit visualParentChanged();
}
void QMenuProxy::clearMenuItems()
{
qDeleteAll(m_items);
m_items.clear();
}
void QMenuProxy::addMenuItem(const QString &text)
{
QMenuItem *item = new QMenuItem(this);
item->setText(text);
m_items << item;
}
void QMenuProxy::showMenu(int x, int y)
{
m_menu->clear();

View File

@ -52,6 +52,8 @@ public:
void showMenu(int x, int y);
Q_INVOKABLE void open();
Q_INVOKABLE void close();
Q_INVOKABLE void clearMenuItems();
Q_INVOKABLE void addMenuItem(const QString &text);
Q_SIGNALS:
void statusChanged();