QCheckbox/QRadioButton 换行 Qt4.6.0 [英] QCheckbox/QRadioButton line wrap Qt4.6.0

查看:49
本文介绍了QCheckbox/QRadioButton 换行 Qt4.6.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用标准 QCheckbox/QRadioButton 在 Qt 中创建一个多行复选框/单选按钮.

I'm trying to have a multi-line checkbox/radiobutton with Qt using standard QCheckbox/QRadioButton.

我没有找到直接的解决方案,因为 QRadioButton{wrap:true;} 没有效果.唯一可能的方法是访问 QRadioButton->label->setLineWrap(true)

I didn't find the direct solution since QRadioButton{wrap:true;} has no effect. The only thing possible would be to access to the QRadioButton->label->setLineWrap(true) but

  1. 我想从设计师那里做到这一点
  2. 不必重写小部件

除了将 QRadioButton 和 QLabel 放在一起之外有什么想法吗?

Any idea beside putting a QRadioButton and a QLabel next to each others?

谢谢,鲍里斯.

推荐答案

这确实很烦人,如果不重新实现就无法解决:如果我没记错的话,标签使用 Qt::PlainText.在我们的项目中,UI 团队通过两种方法解决了这个问题.

That indeed is really annoying and cannot be solved without reimplementation: the label uses Qt::PlainText if I'm not mistaken. In our projects, the UI team solved this with two approaches.

使用 QRadioButton 按钮作为标题

重写 QRadioButton 文本,使其仅包含选项的简要说明.在它下面放一个 QLabel 并添加更长的描述.我们使用较小的字体和一点缩进使其看起来整洁.例如,这在 Mac OS X 中经常使用.

Rewrite the QRadioButton text in such a fashion that it has only a brief description of the option. Put a QLabel underneath it and add a longer description. We use a smaller font and a little indentation to make it look neat. This is used frequently in Mac OS X, for example.

从单选按钮中删除文本

重新布局 UI,以便将每个单选按钮放在 QLabel 的左侧.将整个文本添加到 QLabel 并将标签设置为单选按钮的伙伴.这是功能最少的方法,因为单击标签不会选中单选按钮.另外,对齐也不是很好.

Relayout the UI so that each radio button is put on the left of a QLabel. Add the whole text to the QLabel and set the label as the radio buttons' buddy. This is the least functional approach, because clicking the label does not check the radio button. Also, alignment is not very good.

这篇关于QCheckbox/QRadioButton 换行 Qt4.6.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆