RibbonBar Class

RibbonBar class represents a component Ribbon UI used in Microsoft Office 2007/2010/2013. Please note, after the ribbon bar has been added to the main window you need to setup the Ribbon's style (or MS-Office Style) to the application. To do that please use the following code:. More...

Header: #include <RibbonBar>
Inherits: QMenuBar

Public Types

enum BarPosition { TopPosition, BottomPosition }
enum SearchBarAppearance { SearchBarCentral, SearchBarCompact, SearchBarHidden }

Properties

Public Functions

RibbonBar(QWidget *parent = Q_NULL)
virtual ~RibbonBar()
QAction *addAction(const QIcon &icon, const QString &text, Qt::ToolButtonStyle style, QMenu *menu = Q_NULL)
QAction *addAction(QAction *action, Qt::ToolButtonStyle style)
QMenu *addMenu(const QString &text)
RibbonPage *addPage(const QString &text)
void addPage(RibbonPage *page)
QAction *addSystemButton(const QString &text)
QAction *addSystemButton(const QIcon &icon, const QString &text)
void beginUpdate()
void clearPages()
int currentPageIndex() const
RibbonCustomizeDialog *customizeDialog()
RibbonCustomizeManager *customizeManager()
void detachPage(RibbonPage *page)
void detachPage(int index)
void endUpdate()
RibbonPage *insertPage(int index, const QString &text)
void insertPage(int index, RibbonPage *page)
bool isAcrilycEnabled() const
bool isBackstageVisible() const
bool isContextualTabsVisible() const
bool isFrameThemeEnabled() const
bool isKeyTipsComplement() const
bool isKeyTipsShowing() const
bool isMaximized() const
bool isMinimizationEnabled() const
bool isMinimized() const
bool isMovableTabs() const
bool isTitleGroupsVisible() const
bool keyTipsEnabled() const
QPixmap logoPixmap() const
void maximize()
void minimize()
void movePage(RibbonPage *page, int newIndex)
void movePage(int index, int newIndex)
RibbonPage *page(int index) const
int pageCount() const
RibbonPageList pages() const
RibbonQuickAccessBar *quickAccessBar() const
RibbonBar::BarPosition quickAccessBarPosition() const
void removePage(RibbonPage *page)
void removePage(int index)
RibbonSearchBar *searchBar() const
RibbonBar::SearchBarAppearance searchBarAppearance() const
void setKeyTip(QAction *action, const QString &keyTip)
void setKeyTipsComplement(bool complement)
void setKeyTipsEnable(bool enable)
void setLogoPixmap(const QPixmap &pixmap, Qt::AlignmentFlag alignment)
void setMaximized(bool flag)
void setMinimizationEnabled(bool enabled)
void setMinimized(bool flag)
void setMovableTabs(bool movable)
void setQuickAccessBarPosition(RibbonBar::BarPosition position)
void setSearchBarAppearance(RibbonBar::SearchBarAppearance appearance)
void setSimplifiedMode(bool flag)
void setTabBarPosition(RibbonBar::BarPosition position)
void setTabsElideMode(Qt::TextElideMode mode)
void setTitleBackground(const QPixmap &pixmap)
bool simplifiedMode() const
RibbonSystemButton *systemButton() const
RibbonBar::BarPosition tabBarPosition() const
Qt::TextElideMode tabsElideMode() const
const QPixmap &titleBackground() const
void updateLayout()

Reimplemented Public Functions

virtual QSize sizeHint() const override

Public Slots

void setAcrilycEnabled(bool enabled)
void setContextualTabsVisible(bool visible)
void setCurrentPageIndex(int index)
void setFrameThemeEnabled(bool enabled = true)
void setTitleGroupsVisible(bool visible)
void showCustomizeDialog()

Signals

void currentPageChanged(RibbonPage *page)
void currentPageIndexChanged(int index)
void frameThemeChanged(bool enabled)
void minimizationChanged(bool minimized)
void simplifiedModeChanged(bool enabled)

Static Public Members

bool loadTranslation(const QString &country = QString())

Reimplemented Protected Functions

virtual void changeEvent(QEvent *event) override
virtual bool event(QEvent *event) override
virtual bool eventFilter(QObject *object, QEvent *event) override
virtual void mouseDoubleClickEvent(QMouseEvent *event) override
virtual void mousePressEvent(QMouseEvent *event) override
virtual void paintEvent(QPaintEvent *event) override
virtual void resizeEvent(QResizeEvent *event) override
virtual void wheelEvent(QWheelEvent *event) override

Detailed Description

QApplication app(...);
app.setStyle(new Qtitan::RibbonStyle());

or

QApplication app(...);
app.setStyle("ribbonstyle");

Note: To display RibbonBar correctly the Ribbon style (or Office style) should be installed into your application by calling qApp.setStyle(new Qtitan::RibbonStyle()); or app.setStyle("ribbonstyle"); RibbonBar does not work with platform's specific or standard Qt styles.

Member Type Documentation

enum RibbonBar::BarPosition

This enum describes the position of quick access bar widget on ribbon bar.

ConstantValueDescription
RibbonBar::TopPosition1quick access bar is placed on the title (or the top) of the ribbon.
RibbonBar::BottomPosition2quick access bar is placed on the bottom of the ribbon.

enum RibbonBar::SearchBarAppearance

The enum specifies the position of the search bar on the title of ribbon bar.

ConstantValue
RibbonBar::SearchBarCentral1
RibbonBar::SearchBarCompact2
RibbonBar::SearchBarHidden3

Property Documentation

currentPageIndex : int

Holds the index of the current page.

Access functions:

int currentPageIndex() const
void setCurrentPageIndex(int index)

Notifier signal:

void currentPageIndexChanged(int index)

frameThemeEnabled : bool

This property holds whether display the content for modern Office 2007, 2010, 2013, 2016 styles on the window title bar and activate Windows Air support (applications under Windows 10, 8, 7, Vista) is enabled. By default parameter is enabled. The property supports Windows, Linux and MacOSX.

Access functions:

bool isFrameThemeEnabled() const
void setFrameThemeEnabled(bool enabled = true)

Notifier signal:

void frameThemeChanged(bool enabled)

See also WindowTitleBar.

minimized : bool

Allows to switch the Ribbon Bar to the minimized mode and back.

Access functions:

bool isMinimized() const
void setMinimized(bool flag)

Notifier signal:

void minimizationChanged(bool minimized)

titleGroupsVisible : bool

Sets the visibility of title on all ribbon groups.

Access functions:

bool isTitleGroupsVisible() const
void setTitleGroupsVisible(bool visible)

Member Function Documentation

[explicit] RibbonBar::RibbonBar(QWidget *parent = Q_NULL)

Constructs RibbonBar object with the given parent.

[virtual noexcept] RibbonBar::~RibbonBar()

Destructor of the RibbonBar object.

QAction *RibbonBar::addAction(const QIcon &icon, const QString &text, Qt::ToolButtonStyle style, QMenu *menu = Q_NULL)

Adds button in the upper part of ribbon bar. Parameter icon specifies the icon on the button. Parameter text specifies the button text. Parameter style specifies the button style and parameter menu specifies the pointer to QMenu object. Function returns a pointer to the new QAction object.

QAction *RibbonBar::addAction(QAction *action, Qt::ToolButtonStyle style)

Adds button to the upper part of the ribbon bar associated with an existing action. Parameter style specifies the style of the button.

QMenu *RibbonBar::addMenu(const QString &text)

Adds the menu at the top right ribbon bar with a given text. Returns a pointer to the new object QMenu.

RibbonPage *RibbonBar::addPage(const QString &text)

Adds a new page on RibbonBar. Parameter text is used to initialize the page title. The function returns a pointer to the new object RibbonPage.

void RibbonBar::addPage(RibbonPage *page)

Adds an existing page to the RibbonBar. page - is a pointer to the RibbonPage object.

QAction *RibbonBar::addSystemButton(const QString &text)

Adds system button to the upper left part of ribbon bar. Parameter text specifies the text on the system button. Function returns a pointer to the new QAction object.

QAction *RibbonBar::addSystemButton(const QIcon &icon, const QString &text)

Adds system button to the upper left part of ribbon bar with icon. Parameter text specifies the text on the system button. Parameter icon specifies the icon. Function returns a pointer to the new QAction object.

void RibbonBar::beginUpdate()

Begin an updating the contents of the ribon bar. Use this method to prevent unnecessary calls to rebuild the lay-out at the time of ribbon bar initialization. Using the method allows to significantly increase the speed of creation and filling of the ribbon bar.

See also endUpdate.

[override virtual protected] void RibbonBar::changeEvent(QEvent *event)

Reimplements: QMenuBar::changeEvent(QEvent *e).

void RibbonBar::clearPages()

Removes all pages from the ribbon bar.

[signal] void RibbonBar::currentPageChanged(RibbonPage *page)

The signal is emitted when the active page at the ribbon bar was changed. Parameter page is a reference to the active ribbon page object.

int RibbonBar::currentPageIndex() const

Returns the index of the current page.

Note: Getter function for property currentPageIndex.

See also setCurrentPageIndex().

[signal] void RibbonBar::currentPageIndexChanged(int index)

The signal is emitted when the active page at the ribbon bar was changed. Parameter index - the index of the new active page.

Note: Notifier signal for property currentPageIndex.

RibbonCustomizeDialog *RibbonBar::customizeDialog()

Returns customize dialog. You can use the reference to add custom setting pages to the standard dialog.

See also RibbonCustomizeManager and showCustomizeDialog().

RibbonCustomizeManager *RibbonBar::customizeManager()

Returns customize manager. It is used to configure customization via a special dialog RibbonCustomizeDialog.

See also RibbonCustomizeDialog.

void RibbonBar::detachPage(RibbonPage *page)

Removes page from the ribbon by the given page. Important: The function does not destroy the page.

See also removePage.

void RibbonBar::detachPage(int index)

Removes page from the ribbon by the given position index. Important: The function does not destroy the page at position index.

See also removePage.

void RibbonBar::endUpdate()

Ends the ribbon bar update. The method is always preceded by a call beginUpdate().

[override virtual protected] bool RibbonBar::event(QEvent *event)

Reimplements: QMenuBar::event(QEvent *e).

[override virtual protected] bool RibbonBar::eventFilter(QObject *object, QEvent *event)

Reimplements: QMenuBar::eventFilter(QObject *object, QEvent *event).

RibbonPage *RibbonBar::insertPage(int index, const QString &text)

Creates a new page with the text title and insert it into the position index. The function returns a pointer to the new object RibbonPage.

void RibbonBar::insertPage(int index, RibbonPage *page)

Inserts an existing page at the specified position index of the RibbonBar. The index - is the position of the page, page - a pointer to the new object RibbonPage.

bool RibbonBar::isBackstageVisible() const

Returns the visibility of the BackStage view at the moment.

Note: Getter function for property backstageVisible.

bool RibbonBar::isContextualTabsVisible() const

Returns the visible state for the contextual tabs on the ribbon bar. By default it is true.

Note: Getter function for property contextualTabsVisible.

bool RibbonBar::isKeyTipsComplement() const

Returns the policy of assignment for KeyTips of the buttons and other controls. If return value is true then the keytips assigned automatically, based on keyboard shortcuts <&File, &Open...>. If return value is false keytips will be assigned only if user set it by RibbonBar::setKeyTip() function.

See also setKeyTip().

bool RibbonBar::isKeyTipsShowing() const

Returns the current state of showing Key-Tips. If true then Key-Tips visible on screen at the moment.

bool RibbonBar::isMaximized() const

Returns true if ribbon bar is maximized. Otherwise returns false.

bool RibbonBar::isMinimizationEnabled() const

Returns the enable flag of the minimization feature of the Ribbon Bar.

bool RibbonBar::isMinimized() const

Returns true if ribbon bar is minimized. Otherwise returns false.

Note: Getter function for property minimized.

bool RibbonBar::isMovableTabs() const

This property holds whether the user can move the tabs within the ribbontabbar area.

Note: Getter function for property movableTabs.

See also setMovableTabs(bool).

bool RibbonBar::keyTipsEnabled() const

Returns the flag is mechanizm of Key-Tips enabled or not.

[static] bool RibbonBar::loadTranslation(const QString &country = QString())

Installs translator to QApplication based on country variable. Format variable is de_de, ru_ru, fr_fr. If country is empty then loaded QTranslator based on current locale setting.

QPixmap RibbonBar::logoPixmap() const

Returns the logo pixmap of the ribbon bar.

See also setLogoPixmap().

void RibbonBar::maximize()

Maximizes the ribbon bar if it was minimized before. This is equivalent of setMaximized(true) or setMinimized(false) call.

[signal] void RibbonBar::minimizationChanged(bool minimized)

The signal is used to get notification about changes of the minimization state of the ribbon bar. The parameter minimized contains the current state of the minimization.

Note: Notifier signal for property minimized.

void RibbonBar::minimize()

Minimizes the ribbon bar if it was maximized before. This is equivalent of setMinimized(true) or setMaximized(false) call.

[override virtual protected] void RibbonBar::mouseDoubleClickEvent(QMouseEvent *event)

Reimplements: QWidget::mouseDoubleClickEvent(QMouseEvent *event).

[override virtual protected] void RibbonBar::mousePressEvent(QMouseEvent *event)

Reimplements: QMenuBar::mousePressEvent(QMouseEvent *e).

void RibbonBar::movePage(RibbonPage *page, int newIndex)

Moves the page from current position to the position newIndex.

void RibbonBar::movePage(int index, int newIndex)

Moves the page in the position index to the position newIndex.

RibbonPage *RibbonBar::page(int index) const

Returns the ribbon page by index. See description of class RibbonPage for more details.

int RibbonBar::pageCount() const

Returns the number of the pages inside the ribbon bar.

RibbonPageList RibbonBar::pages() const

Returns the list of all pages in the ribbon bar.

[override virtual protected] void RibbonBar::paintEvent(QPaintEvent *event)

Reimplements: QMenuBar::paintEvent(QPaintEvent *e).

RibbonQuickAccessBar *RibbonBar::quickAccessBar() const

Returns pointer to the quick access bar. See description of class RibbonQuickAccessBar for more details.

RibbonBar::BarPosition RibbonBar::quickAccessBarPosition() const

Retruns current position of quick access bar on the ribbon bar.

Note: Getter function for property quickAccessBarPosition.

See also setQuickAccessBarPosition().

void RibbonBar::removePage(RibbonPage *page)

Removes an existing page. Parameter page is a pointer to page that will be removed. The object that is referenced by page will be destroyed.

See also detachPage.

void RibbonBar::removePage(int index)

Removes the page at the given index. An object that represents the page at position index will be destroyed.

See also detachPage.

[override virtual protected] void RibbonBar::resizeEvent(QResizeEvent *event)

Reimplements: QMenuBar::resizeEvent(QResizeEvent *).

Returns pointer to the search bar. See description of class RibbonSearchBar for more details.

[slot] void RibbonBar::setContextualTabsVisible(bool visible)

Sets the visible state for the contextual tabs defined by visible parameter.

Note: Setter function for property contextualTabsVisible.

See also isContextualTabsVisible().

[slot] void RibbonBar::setCurrentPageIndex(int index)

Make a page in the position specified by index, the current one.

Note: Setter function for property currentPageIndex.

See also currentPageIndex().

void RibbonBar::setKeyTip(QAction *action, const QString &keyTip)

Sets the keyTip for the control associated with given action. Function is taken effect if RibbonBar::isKeyTipsComplement() return true.

See also setKeyTipsComplement().

void RibbonBar::setKeyTipsComplement(bool complement)

The function sets the policy of assignment for KeyTips of the buttons and other controls. If the parameter complement is true then the keytips assigned automatically, based on keyboard shortcuts <&File, &Open...>. If parameter complement is false keytips will be assigned only if user set it by RibbonBar::setKeyTip() function.

See also isKeyTipsComplement() and setKeyTip().

void RibbonBar::setKeyTipsEnable(bool enable)

Enabled or disabled mechanizm of Key-Tips.

void RibbonBar::setLogoPixmap(const QPixmap &pixmap, Qt::AlignmentFlag alignment)

Sets custom logo pixmap for the ribbon bar. Logo can be aligned at the left or at the right of the ribbon bar.

See also logoPixmap().

void RibbonBar::setMaximized(bool flag)

Sets maximized flag for the ribbon bar.

See also isMaximized().

void RibbonBar::setMinimizationEnabled(bool enabled)

Sets the minimization feature of the Ribbon Bar to the enabled.

See also isMinimizationEnabled().

void RibbonBar::setMinimized(bool flag)

Sets minimized flag for the ribbon bar.

Note: Setter function for property minimized.

See also isMinimized().

void RibbonBar::setQuickAccessBarPosition(RibbonBar::BarPosition position)

Sets quick access bar position on the ribbon bar.

Note: Setter function for property quickAccessBarPosition.

See also quickAccessBarPosition().

void RibbonBar::setTabBarPosition(RibbonBar::BarPosition position)

Sets tabs position on the ribbon bar.

Note: Setter function for property tabBarPosition.

See also tabBarPosition().

void RibbonBar::setTitleBackground(const QPixmap &pixmap)

Sets the background image for the title of the ribbon bar.

Note: Setter function for property titleBackground.

See also titleBackground().

[slot] void RibbonBar::showCustomizeDialog()

Shows customization dialog related to customizeDialog() function. Dialog is shown in modal mode to window that holds a ribbon bar.

See also customizeDialog.

[override virtual] QSize RibbonBar::sizeHint() const

Reimplements: QMenuBar::sizeHint() const.

RibbonSystemButton *RibbonBar::systemButton() const

Returns pointer to the RibbonSystemButton object.

RibbonBar::BarPosition RibbonBar::tabBarPosition() const

Retruns current position of tabs on the ribbon bar.

Note: Getter function for property tabBarPosition.

See also setTabBarPosition().

const QPixmap &RibbonBar::titleBackground() const

Returns the current background image of the ribbon bar title.

Note: Getter function for property titleBackground.

See also setTitleBackground().

void RibbonBar::updateLayout()

Performs a full rebuild of the ribbon bar layout.

[override virtual protected] void RibbonBar::wheelEvent(QWheelEvent *event)

Reimplements: QWidget::wheelEvent(QWheelEvent *event).