Comments (6)
在SARibbonBar::RibbonStyle
中有4种模式,其中以TwoRow结尾的是可以指定文本是否换行,非TwoRow结尾都是会换行,决定是否换行通过静态函数:SARibbonToolButton::setLiteStyleEnableWordWrap
来设置,这个函数需要在构建ui之前调用,否则需要全部刷新才看到效果。在例子中有相关例子,由于我在用手机没法给你截图。
例子里面有个word wrap in 2row的按钮,切换后需要切换一下ribbon的style,强制重新计算尺寸才能看到效果
from saribbon.
我这边选用的是wps风格(非两行),我这边发现三行模式下是否换行好像是跟文字的长度有关。当文字长度足够长的时候才会换行。是否有一些机制(检验到字符串中间有空格),可以强制三行模式下换行?
我是将mainwindow.cpp中的部分代码修改如下:
# 修改save按扭的字符串
QAction* actSave = createAction(tr("New Terminal"), ":/icon/icon/save.svg");
# 修改 show context 的字符串
QAction* actShowContext = createAction(tr("new Script"), ":/icon/icon/showContext.svg");
# 修改 delete context 的字符串
QAction* actDeleteContext = createAction(tr("create Script"), ":/icon/icon/deleteContext.svg");
Plus: 刚发现了一种解决方案,代码如下图:
# 在new和script中间空格多一些
QAction* act_new_script= createAction(tr("new Script"), ":/image/image/save.png");
from saribbon.
一个新的问题是我这边用Qt6.2无法编译成功,只能用Qt5.15编写
from saribbon.
qt6没试过,你可以提到新的issues里,我专门处理一下
from saribbon.
我这边选用的是wps风格(非两行),我这边发现三行模式下是否换行好像是跟文字的长度有关。当文字长度足够长的时候才会换行。是否有一些机制(检验到字符串中间有空格),可以强制三行模式下换行?
我是将mainwindow.cpp中的部分代码修改如下:
# 修改save按扭的字符串 QAction* actSave = createAction(tr("New Terminal"), ":/icon/icon/save.svg"); # 修改 show context 的字符串 QAction* actShowContext = createAction(tr("new Script"), ":/icon/icon/showContext.svg"); # 修改 delete context 的字符串 QAction* actDeleteContext = createAction(tr("create Script"), ":/icon/icon/deleteContext.svg");
Plus: 刚发现了一种解决方案,代码如下图:
# 在new和script中间空格多一些 QAction* act_new_script= createAction(tr("new Script"), ":/image/image/save.png");
换行的确和文字长度有关,在src/SARibbonBar/SARibbonToolButton.cpp中,会对文字长度进行评估,可见:void SARibbonToolButton::reCalcSizeHint(QSize s)
的这一段:
//! 1 先获取最优的文字textRange
{
const int maxTrycount = 3;
int trycount = 0;
int alignment = Qt::TextShowMnemonic | Qt::TextWordWrap;
do {
//先计算两行文本的紧凑矩形
//从一半开始逐渐递增
textRange.setWidth(s.width() / 2 + (s.width() / 2) * (float(trycount) / maxTrycount));
textRange = fm.boundingRect(textRange, alignment, text());
if (textRange.height() <= (fm.lineSpacing() * 2)) {
//保证在两行
m_isWordWrap = (textRange.height() > fm.lineSpacing());
break;
}
++trycount;
} while (trycount < 3);
}
我会尝试3次,以保证得到一个较为紧凑的文本
from saribbon.
好的,感谢
from saribbon.
Related Issues (20)
- Window titlebar not showing on classic menubar mode HOT 2
- SARibbonToolButton伪状态字体颜色 HOT 2
- 多屏幕下 副屏的按钮无法正常显示 HOT 1
- 修改 quickAccessBar 图标大小没有效果 HOT 1
- 将源码引入工程成一个子模块,通过静态链接方式链接报错 HOT 1
- 把Qt3DExtras::Qt3DWindow放进SARibbonMainWindow时起始位置往左偏移 HOT 7
- Implement ApplicationToolButton Dialog in MSOffice 2013 style HOT 3
- SARibbonBar布局議題 HOT 4
- 请问SARibbonMainWindow 右上角的最大化、最小化、关闭三个按钮如何去掉或隐藏呢? HOT 1
- 笔记本为1080p, 外接屏幕为4k屏,最大化窗口异常 HOT 2
- SARibbon in QT Designer HOT 1
- 是否支持Qt的*.qm翻译文件? HOT 3
- StyleSheet議題 HOT 3
- SARibbonCategory中添加SARibbonPannel,然后再SARibbonPannel中添加QAction,名称过长无法自适应QAction的宽度 HOT 3
- ui->setupUi(this);之后看不到saribbon HOT 1
- 图标大小不一致
- SystemButton 关闭按钮位置异常 HOT 12
- SystemButton最大化按钮Windows11特性显示位置偏下方 HOT 1
- 自定义的样式 applicationButton 高度受限 HOT 1
- 解析Ribbon的按钮,可用于autoTest解析automation id
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from saribbon.