将单选按钮设置为组框标题 [英] Setting radio button as group box title

查看:140
本文介绍了将单选按钮设置为组框标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在qml中将单选按钮作为组框标题放置。如果可以的话,您能给我一些提示怎么做。我看到可以将标题更改为复选框的选项,但是它不能解决我的问题。

Is it possible to place radio button as group box header in qml. If yest can you give me some hint how can be done. I saw option to change title to check box but it doesn't feet my solution.

推荐答案

当前无法执行此操作与 GroupBox 一起使用,因为它不提供样式API。您有以下选择:

It's not currently possible to do this with GroupBox, as it doesn't offer a styling API. You have these options:


  1. 使用 checkable 属性,该属性为 CheckBox ,而不是众所周知的 RadioButton

  2. 使用私有< a href = http://code.qt.io/cgit/qt/qtquickcontrols.git/tree/src/controls/Styles/Base/GroupBoxStyle.qml rel = nofollow> GroupBoxStyle 类型,然后定义自己的 复选框 组件,它是 RadioButton 。但是,这是私有API,这意味着它可以随时更改。

  3. 以某种方式将非交互式但可视的项放在 CheckBox checkable 属性生成的c $ c>,并过滤将转到该复选框的事件。

  4. 使用我链接的代码编写自己的 GroupBox 以上为起点。

  1. Use the checkable property, which gives you a CheckBox, not a RadioButton, as you know.
  2. Use the private GroupBoxStyle type and then define your own checkbox component that is a RadioButton. This is private API though, which means it can change at any point.
  3. Somehow place a non-interactive but visual item over the top of the CheckBox that is produced with the checkable property, and filter the events that would go to that checkbox. This is quite difficult, and I'm not sure if it would work.
  4. Write your own GroupBox, using the code I linked to above as a starting point.

这篇关于将单选按钮设置为组框标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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