The QMenuView provides a menu based view on a QAbstractItemModel class. More...

#include <qmenuview.h>

Inheritance diagram for QMenuView:

List of all members.

Signals

void hovered (const QString &text) const
 The signal when a menu action is highlighted.
void triggered (const QModelIndex &index) const
 This signal is emitted when an action in this menu is triggered.

Public Member Functions

 QMenuView (QWidget *parent=0)
 Creates the new menu view based on a QMenu object.
virtual ~QMenuView ()
 Destroy the menu.
virtual void setModel (QAbstractItemModel *model)
 Set the new model to model.
QAbstractItemModelmodel () const
 Return the current model of the menu.
virtual void setRootIndex (const QModelIndex &index)
 Change the root index to index.
QModelIndex rootIndex () const
 Returns the current root index.

Protected Member Functions

virtual bool prePopulated ()
 Add any actions before the tree, return true if any actions are added.
virtual void postPopulated ()
 Add any actions after the tree.
void createMenu (const QModelIndex &parent, QMenu *parentMenu=0, QMenu *menu=0)
 Puts all of the children of parent into menu.

Detailed Description

The QMenuView provides a menu based view on a QAbstractItemModel class.

Since:
0.9.0.0
Binary Compatible:
0.10.0.0

This class is used to transform a hierarchical model based on the class QAbstractItemModel into a menu. It can be used to create an action menu, history, or snipets menu.

qmenuview.png

When the model is defined, the structure of the menu is automatically generated. This class ignores call to QAbstractItemModel::beginInsertRows() and QAbstractItemModel::endInsertRows(). Menu is generated when the user opens it.


Constructor & Destructor Documentation

QMenuView::QMenuView ( QWidget parent = 0  ) 

Creates the new menu view based on a QMenu object.

Parameters:
parent The parent object of the menu.
QMenuView::~QMenuView (  )  [virtual]

Destroy the menu.


Member Function Documentation

void QMenuView::createMenu ( const QModelIndex parent,
QMenu parentMenu = 0,
QMenu menu = 0 
) [protected]

Puts all of the children of parent into menu.

void QMenuView::hovered ( const QString text  )  const [signal]

The signal when a menu action is highlighted.

text is the Qt::StatusTipRole of the index that caused the signal to be emitted.

Often this is used to update status information.

See also:
triggered()
QAbstractItemModel * QMenuView::model (  )  const

Return the current model of the menu.

void QMenuView::postPopulated (  )  [protected, virtual]

Add any actions after the tree.

bool QMenuView::prePopulated (  )  [protected, virtual]

Add any actions before the tree, return true if any actions are added.

Reimplemented in SnipetMenu.

QModelIndex QMenuView::rootIndex (  )  const

Returns the current root index.

Default root index is QModelIndex()

void QMenuView::setModel ( QAbstractItemModel model  )  [virtual]

Set the new model to model.

Parameters:
model The new model to use for the creation of menus.
void QMenuView::setRootIndex ( const QModelIndex index  )  [virtual]

Change the root index to index.

This can be used to show only a part of the QAbstractItemModel.

Parameters:
index The index to use to show the menu. if QModelIndex(), all the model is show.
void QMenuView::triggered ( const QModelIndex index  )  const [signal]

This signal is emitted when an action in this menu is triggered.

index is the index's action that caused the signal to be emitted.

See also:
hovered()