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

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

问题描述

我想有一个多行复选框/单选按钮与Qt使用标准QCheckbox / QRadioButton。



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


  1. 我想从设计者那样做

  2. 不必重写小部件

除了将QRadioButton和QLabel放在彼此旁边之外还有什么想法?



Thx,Boris。

$这确实是恼人的,不能解决没有重新实现:标签使用 Qt :: PlainText

c>如果我没有误。在我们的项目中,UI团队使用两种方法解决了这个问题。



使用QRadioButton按钮作为标题



以这样的方式重写QRadioButton文本,它只有选项的简要描述。在它下面放一个QLabel,并添加一个更长的描述。我们使用较小的字体和一个小缩进,使其看起来整洁。



从单选按钮中删除文本





继电器UI,使每个单选按钮放在QLabel的左边。将整个文本添加到QLabel并将标签设置为单选按钮的好友。这是最不起作用的方法,因为单击标签不会检查单选按钮。此外,对齐不是很好。


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

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. I'd like to do that from the designer
  2. not having to rewrite a widget

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

Thx, Boris.

解决方案

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.

Using the QRadioButton button as a title

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.

Removing the text from the radio button

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天全站免登陆