Qt Ribbon使用实例

采用SARibbon创建简单的ribbon界面

实例代码如下所示:

1、头文件:

#pragma once

#include <SARibbonBar.h>

#include "SARibbonMainWindow.h"

class QTextEdit;

class SAProjectDemo1 : public SARibbonMainWindow

{

Q_OBJECT

public:

SAProjectDemo1(QWidget *parent = Q_NULLPTR);

QAction* createAction(const QString& text, const QString& iconurl);

QTextEdit *mTextedit;

};

2、源文件

#include "SAProjectDemo1.h"

#include <QTextEdit>

#include <QStatusBar>

SAProjectDemo1::SAProjectDemo1(QWidget *parent)

: SARibbonMainWindow(parent)

{

setWindowTitle(("ribbon mainwindow test"));

setRibbonTheme(SARibbonTheme::RibbonThemeOffice2021Blue);

SARibbonBar* pRibbonBar = ribbonBar();

//

SARibbonCategory* page1 = new SARibbonCategory();

page1->setCategoryName("page1");

SARibbonPannel* pannel1 = new SARibbonPannel("pannel1", page1);

{

QAction* act = createAction("Demo", ":/SAProjectDemo1/Res/fullscreen.png");

act->setIconText("save1");

connect(act, &QAction::triggered, this, [this, act]()

{

});

pannel1->addLargeAction(act);

}

{

QAction* act = createAction("Demo", ":/SAProjectDemo1/Res/fullscreen.png");

act->setIconText("save2");

connect(act, &QAction::triggered, this, [this, act]()

{

});

pannel1->addLargeAction(act);

}

{

QAction* act = createAction("Demo", ":/SAProjectDemo1/Res/fullscreen.png");

act->setIconText("save3");

connect(act, &QAction::triggered, this, [this, act]()

{

});

pannel1->addLargeAction(act);

}

page1->addPannel(pannel1);

//

SARibbonPannel* pannel12 = new SARibbonPannel("pannel12", page1);

page1->addPannel(pannel12);

{

QAction* act = createAction("Demo", ":/SAProjectDemo1/Res/fullscreen.png");

act->setIconText("save");

connect(act, &QAction::triggered, this, [this, act]()

{

});

pannel12->addLargeAction(act);

}

pRibbonBar->addCategoryPage(page1);

//

SARibbonCategory* page2 = new SARibbonCategory();

page2->setCategoryName("page2");

SARibbonPannel* pannel2 = new SARibbonPannel("pannel2", page2);

{

QAction* act = createAction("Demo", ":/SAProjectDemo1/Res/fullscreen.png");

act->setIconText("save");

connect(act, &QAction::triggered, this, [this, act]()

{

});

pannel2->addLargeAction(act);

}

page2->addPannel(pannel2);

pRibbonBar->addCategoryPage(page2);

mTextedit = new QTextEdit(this);

setCentralWidget(mTextedit);

//

setStatusBar(new QStatusBar());

resize(800, 600);

}

QAction* SAProjectDemo1::createAction(const QString& text, const QString& iconurl)

{

QAction* act = new QAction(this);

act->setText(text);

act->setIcon(QIcon(iconurl));

act->setObjectName(text);

return act;

}

相关推荐
春蕾夏荷_7282977253 天前
MFC 创建Ribbon样式窗口
ribbon·mfc
xwLink199612 天前
VB.net实战(VSTO):解决WPS Ribbon图标灰色背景
后端·spring cloud·ribbon
扬子鳄0081 个月前
Ribbon和Eureka的集成
spring cloud·eureka·ribbon
guihong0041 个月前
深入理解 Spring Cloud 中的 Eureka、Ribbon 和 Feign
spring cloud·eureka·ribbon
张敬之、1 个月前
Ribbon
后端·spring cloud·ribbon
跳跳的向阳花2 个月前
03-08、SpringCloud第八章,升级篇,负载均衡与服务调用Ribbon和OpenFeign
spring cloud·ribbon·负载均衡
BestandW1shEs2 个月前
快速理解微服务中Ribbon的概念
微服务·ribbon
yours_Gabriel2 个月前
【微服务】 Eureka和Ribbon
java·微服务·eureka·ribbon
跳跳的向阳花2 个月前
03-03、SpringCloud第三章,负载均衡Ribbon和Feign
spring cloud·ribbon·负载均衡