KanoopGuiQt 1.3.0
Qt GUI utility library
Loading...
Searching...
No Matches
SidebarWidget Class Reference

Icon-and-text sidebar navigation widget backed by QStandardItemModel. More...

#include <sidebarwidget.h>

+ Inheritance diagram for SidebarWidget:
+ Collaboration diagram for SidebarWidget:

Signals

void itemClicked (int entityType)
 Emitted when the user clicks a sidebar entry.
 

Public Member Functions

 SidebarWidget (QWidget *parent=nullptr)
 Construct with an optional parent.
 
void addItem (int entityMetadataType, const QString &text, int imageResourceId=0)
 Add an entry to the sidebar.
 
void removeItem (int entityMetadataType)
 Remove the entry with the given entity type.
 
bool containsItem (int entityMetadataType) const
 Return whether an entry with the given entity type exists.
 
void clear ()
 Remove all entries from the sidebar.
 
void selectItem (int entityMetadataType)
 Programmatically select the entry with the given entity type.
 
QMargins contentsMargins () const
 Return the content margins used by the paint delegate.
 
void setContentsMargins (const QMargins &value)
 Set the content margins used by the paint delegate.
 
int horizontalSpacing () const
 Return the horizontal spacing between the icon and text.
 
void setHorizontalSpacing (int value)
 Set the horizontal spacing between the icon and text.
 
int verticalSpacing () const
 Return the vertical spacing between entries.
 
void setVerticalSpacing (int value)
 Set the vertical spacing between entries.
 
QSize iconSize () const
 Return the icon size used when rendering entries.
 
void setIconSize (const QSize &value)
 Set the icon size used when rendering entries.
 

Detailed Description

Icon-and-text sidebar navigation widget backed by QStandardItemModel.

SidebarWidget displays a vertical list of named, optionally-iconed navigation entries. Each entry is keyed by an entity metadata type integer. Clicking an entry emits itemClicked() with the entity type. Spacing, icon size, and content margins are all adjustable.

Definition at line 19 of file sidebarwidget.h.

Constructor & Destructor Documentation

◆ SidebarWidget()

SidebarWidget::SidebarWidget ( QWidget *  parent = nullptr)
explicit

Construct with an optional parent.

Parameters
parentOptional QWidget parent

Member Function Documentation

◆ addItem()

void SidebarWidget::addItem ( int  entityMetadataType,
const QString &  text,
int  imageResourceId = 0 
)

Add an entry to the sidebar.

Parameters
entityMetadataTypeInteger key for the entry
textDisplay text
imageResourceIdOptional Qt resource ID for the entry icon (0 = none)

◆ containsItem()

bool SidebarWidget::containsItem ( int  entityMetadataType) const

Return whether an entry with the given entity type exists.

Parameters
entityMetadataTypeEntity type key to check
Returns
true if the entry is present

◆ contentsMargins()

QMargins SidebarWidget::contentsMargins ( ) const

Return the content margins used by the paint delegate.

Returns
Content margins

◆ horizontalSpacing()

int SidebarWidget::horizontalSpacing ( ) const

Return the horizontal spacing between the icon and text.

Returns
Horizontal spacing in pixels

◆ iconSize()

QSize SidebarWidget::iconSize ( ) const

Return the icon size used when rendering entries.

Returns
Icon size

◆ itemClicked

void SidebarWidget::itemClicked ( int  entityType)
signal

Emitted when the user clicks a sidebar entry.

Parameters
entityTypeEntity type key of the clicked entry

◆ removeItem()

void SidebarWidget::removeItem ( int  entityMetadataType)

Remove the entry with the given entity type.

Parameters
entityMetadataTypeEntity type key of the entry to remove

◆ selectItem()

void SidebarWidget::selectItem ( int  entityMetadataType)

Programmatically select the entry with the given entity type.

Parameters
entityMetadataTypeEntity type key to select

◆ setContentsMargins()

void SidebarWidget::setContentsMargins ( const QMargins &  value)

Set the content margins used by the paint delegate.

Parameters
valueNew content margins

◆ setHorizontalSpacing()

void SidebarWidget::setHorizontalSpacing ( int  value)

Set the horizontal spacing between the icon and text.

Parameters
valueHorizontal spacing in pixels

◆ setIconSize()

void SidebarWidget::setIconSize ( const QSize &  value)

Set the icon size used when rendering entries.

Parameters
valueNew icon size

◆ setVerticalSpacing()

void SidebarWidget::setVerticalSpacing ( int  value)

Set the vertical spacing between entries.

Parameters
valueVertical spacing in pixels

◆ verticalSpacing()

int SidebarWidget::verticalSpacing ( ) const

Return the vertical spacing between entries.

Returns
Vertical spacing in pixels

The documentation for this class was generated from the following file: