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

Vertically stacked collapsible-panel (accordion) widget. More...

#include <accordionwidget.h>

+ Inheritance diagram for AccordionWidget:
+ Collaboration diagram for AccordionWidget:

Public Slots

virtual void onPreferencesChanged ()
 Called when application preferences change; reapplies styling.
 

Signals

void itemCountModified ()
 Emitted when a panel is added or removed.
 

Public Member Functions

 AccordionWidget (QWidget *parent=nullptr)
 Construct with an optional parent widget.
 
void addItem (const QString &title, QWidget *content)
 Append a new panel at the end.
 
void insertItem (int index, const QString &title, QWidget *content)
 Insert a new panel at a specific position.
 
void removeItem (int index)
 Remove the panel at the given index.
 
void setItemVisible (int index, bool visible)
 Show or hide the panel at the given index.
 
void clear ()
 Remove all panels from the widget.
 
void expandAll ()
 Expand all panels.
 
void collapseAll ()
 Collapse all panels.
 
void setExpanded (QWidget *widget, bool expanded)
 Expand or collapse the panel containing the given content widget.
 
bool isExpanded (QWidget *widget) const
 Return whether the panel containing the given content widget is expanded.
 
bool areAllExpanded () const
 Return whether all panels are currently expanded.
 
bool areAllCollapsed () const
 Return whether all panels are currently collapsed.
 
void setTitle (QWidget *widget, const QString &title)
 Change the title of the panel containing the given content widget.
 
int indexOf (QWidget *widget) const
 Return the index of the panel containing the given content widget.
 
int count () const
 Return the number of panels.
 

Detailed Description

Vertically stacked collapsible-panel (accordion) widget.

AccordionWidget manages a list of AccordionItem panels, each with a title button and a content widget. Items can be added, removed, expanded, and collapsed individually or all at once.

Definition at line 17 of file accordionwidget.h.

Constructor & Destructor Documentation

◆ AccordionWidget()

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

Construct with an optional parent widget.

Parameters
parentOptional QWidget parent

Member Function Documentation

◆ addItem()

void AccordionWidget::addItem ( const QString &  title,
QWidget *  content 
)

Append a new panel at the end.

Parameters
titleTitle shown on the panel's header button
contentWidget displayed when the panel is expanded

◆ areAllCollapsed()

bool AccordionWidget::areAllCollapsed ( ) const

Return whether all panels are currently collapsed.

Returns
true if every panel is collapsed

◆ areAllExpanded()

bool AccordionWidget::areAllExpanded ( ) const

Return whether all panels are currently expanded.

Returns
true if every panel is expanded

◆ count()

int AccordionWidget::count ( ) const

Return the number of panels.

Returns
Panel count

◆ indexOf()

int AccordionWidget::indexOf ( QWidget *  widget) const

Return the index of the panel containing the given content widget.

Parameters
widgetContent widget to look up
Returns
Zero-based index, or -1 if not found

◆ insertItem()

void AccordionWidget::insertItem ( int  index,
const QString &  title,
QWidget *  content 
)

Insert a new panel at a specific position.

Parameters
indexZero-based position to insert at
titleTitle shown on the panel's header button
contentWidget displayed when the panel is expanded

◆ isExpanded()

bool AccordionWidget::isExpanded ( QWidget *  widget) const

Return whether the panel containing the given content widget is expanded.

Parameters
widgetContent widget identifying the panel
Returns
true if the panel is expanded

◆ removeItem()

void AccordionWidget::removeItem ( int  index)

Remove the panel at the given index.

Parameters
indexZero-based index of the panel to remove

◆ setExpanded()

void AccordionWidget::setExpanded ( QWidget *  widget,
bool  expanded 
)

Expand or collapse the panel containing the given content widget.

Parameters
widgetContent widget identifying the panel
expandedtrue to expand, false to collapse

◆ setItemVisible()

void AccordionWidget::setItemVisible ( int  index,
bool  visible 
)

Show or hide the panel at the given index.

Parameters
indexZero-based index of the panel
visibletrue to show, false to hide

◆ setTitle()

void AccordionWidget::setTitle ( QWidget *  widget,
const QString &  title 
)

Change the title of the panel containing the given content widget.

Parameters
widgetContent widget identifying the panel
titleNew title text

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