MCPcopy Create free account
hub / github.com/czyt1988/SARibbon / MainWindow

Method MainWindow

example/UseNativeFrameExample/mainwindow.cpp:62–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 } while (0)
61
62MainWindow::MainWindow(QWidget* par, SARibbonMainWindowStyles style) : SARibbonMainWindow(par, style)
63{
64 setWindowTitle(("ribbon use native frame test[*]"));
65 setWindowModified(true);
66 mTextedit = new QTextEdit(this);
67 setCentralWidget(mTextedit);
68 setStatusBar(new QStatusBar());
69
70 SARibbonBar* ribbon = ribbonBar();
71 //! 通过setContentsMargins设置ribbon四周的间距
72 ribbon->setContentsMargins(5, 0, 5, 0);
73
74 connect(ribbon, &SARibbonBar::actionTriggered, this, [ this ](QAction* action) {
75 mTextedit->append(QString("action object name=%1 triggered").arg(action->objectName()));
76 });
77
78 //! cn:
79 //! 这里示例的是如何设置和修改applicationButton,默认情况下SARibbonBar会创建一个SARibbonApplicationButton,
80 //! SARibbonApplicationButton的父类是QToolButton,用户也可以创建自己的applicationButton,
81 //! 通过SARibbonBar::setApplicationButton函数设置自己定义的按钮,如果传入一个空指针,将取消掉applicationButton
82 //! en:
83 //! Here is an example of how to set and modify the applicationButton. By default,
84 //! SARibbonBar will create a SARibbonApplicationButton. The parent class of SARibbonApplicationButton is QToolButton.
85 //! Users can also create their own applicationButton, and set their own buttons through the SARibbonBar::setApplicationButton function.
86 //! If a null pointer is passed in, the applicationButton will be canceled
87 createRibbonApplicationButton();
88
89 //! cn:
90 //! 添加主标签页,这里演示通过SARibbonBar::addCategoryPage函数添加一个标签页
91 //! en:
92 //! Add the main tab. Here we show how to add a tab through the SARibbonBar::addCategoryPage function
93 SARibbonCategory* categoryMain = ribbon->addCategoryPage(tr("&Main"));
94 //! cn: SARibbonBar的Category和Panel,以及对应的Action都应该设置ObjectName,因为如果要自定义action,这些ObjectName是必不可少的
95 //! en: The category , panel and actions of SARibbonBar, should be set with Object Names, as these Object Names are essential for customizing actions
96 categoryMain->setObjectName(("categoryMain"));
97 createCategoryMain(categoryMain);
98
99 //! cn:这里演示了另外一种添加标签页的方式,先创建SARibbonCategory指针,并通过SARibbonBar::addCategoryPage函数把SARibbonCategory指针传递给SARibbonBar
100 //! en:Here is another way to add a tab: first create a SARibbonCategory pointer and pass it to SARibbonBar through the SARibbonBar::addCategoryPage function
101 SARibbonCategory* categoryOther = new SARibbonCategory();
102 categoryOther->setCategoryName(tr("Other"));
103 categoryOther->setObjectName(("categoryOther"));
104 createCategoryOther(categoryOther);
105 ribbon->addCategoryPage(categoryOther);
106
107 createContextCategory();
108
109 //! cn:
110 //! 创建RightButtonGroup,RightButtonGroup类似一个在右上角的工具栏,给用户放置一些快捷图标,例如关于、帮助等图标,
111 //! RightButtonGroup在SARibbonBar创建时就会构建一个默认的SARibbonButtonGroupWidget,可以通过SARibbonBar::rightButtonGroup函数获取
112 //! en:
113 //! Create a RightButtonGroup, which is similar to a toolbar in the upper right corner,
114 //! providing users with shortcut icons such as About, Help, etc. RightButtonGroup will build a default SARibbonButtonGroupWidget when creating SARibbonBar,
115 //! which can be obtained through the SARibbonBar::rightButtonGroup function
116 createRightButtonGroup();
117
118 //! cn:
119 //! 这里演示了如何在系统窗口最小化最大化关闭按钮旁边添加其他按钮

Callers

nothing calls this directly

Calls 4

appendMethod · 0.45
addCategoryPageMethod · 0.45
setCategoryNameMethod · 0.45
setRibbonStyleMethod · 0.45

Tested by

no test coverage detected