class QDial#

QDial类实现了圆形范围控件(如速度表或电位器)。更多信息...

Inheritance diagram of PySide6.QtWidgets.QDial

概述#

属性#

方法#

虚拟方法#

槽函数#

备注

此文档可能包含自动从C++转换为Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译有问题,您也可以通过在https:/bugreports.qt.io/projects/PYSIDE上创建票证来告诉我们

详细说明#

../../_images/windows-dial.png

QDial 在用户需要在程序定义的范围内控制一个值时使用,范围可以是循环的(例如,角度测量从0度到359度)或者对话框布局需要一个方形小部件。

因为 QDial 继承自 QAbstractSlider ,旋钮的行为与 slider 类似。当 wrapping() 为false(默认设置)时,滑块和旋钮之间实际上没有真正的区别。它们共享相同的信号、槽和成员函数。您使用哪一个取决于用户的期望和应用程序的类型。

旋钮最初在滑块被移动时连续发出 valueChanged() 信号;您可以通过禁用 tracking 属性来降低信号的发出频率。即使禁用了跟踪,也会持续发出 sliderMoved() 信号。

当鼠标按钮按下和释放时,旋钮还会发出 sliderPressed()sliderReleased() 信号。请注意,即使没有发出这些信号,旋钮的值也可以改变,因为键盘和滚轮也可以用来改变值。

与滑块不同,QDial 尝试绘制尽可能多的“美观”刻度,而不是每行一步一个。如果可能的话,每行一步绘制一个刻度,但如果像素不足,QDial 将跳过一些刻度以尝试绘制一组均匀的刻度(例如,每隔一个或两个刻度绘制)。

与滑块类似,拨盘将 QAbstractSlider 函数 setValue() 作为槽提供。

拨盘的键盘界面相对简单:左/上箭头和右/下箭头键通过已定义的 singleStep 调整拨盘的 value,Page Up 和 Page Down 通过已定义的 pageStep,Home 和 End 键将值设置到定义的 minimummaximum 之间。

如果您正在使用鼠标轮调整拨盘,增量值由小于 wheelScrollLines 乘以 singleSteppageStep 的值来决定。

备注

当使用 from __feature__ import true_property 时,可以直接使用属性,否则通过访问器函数。

属性notchSize<strong>:</strong></em><code class="xref py py-meth docutils literal notranslate"><span class="pre">int</span></code><a class="headerlink" href="#PySide6.QtWidgets.QDial.notchSize" title="链接到这个定义">#</a></dt> <dd></dd></dl> <p>此属性保存当前刻度大小。</p> <p>凹口大小以范围控制单位表示,而不是像素,并将其计算为一个<code class="xref py py-meth docutils literal notranslate">singleStep()</code>的倍数,该倍数导致屏幕上的凹口大小接近<code class="xref py py-meth docutils literal notranslate">notchTarget()</code>。</p> <blockquote> <div><div class="admonition seealso"> <p class="admonition-title">另请参阅</p> <p><a class="reference internal" href="#id1" title="PySide6.QtWidgets.QDial.notchTarget"><code class="xref py py-meth docutils literal notranslate">notchTarget()</code></a> <a class="reference internal" href="QAbstractSlider.html#id6" title="PySide6.QtWidgets.QAbstractSlider.singleStep"><code class="xref py py-meth docutils literal notranslate">singleStep()</code></a></p> </div> </div></blockquote> <dl class="simple"> <dt><strong>访问函数</strong></dt><dd><ul class="simple"> <li><p><a class="reference internal" href="#id0" title="PySide6.QtWidgets.QDial.notchSize"><code class="xref py py-meth docutils literal notranslate"><span class="pre">notchSize()</span></code></a></p></li> </ul> </dd> </dl> <dl class="py property"> <dt class="sig sig-object py" id="PySide6.QtWidgets.QDial.notchTarget"> <em class="property">属性</em><em class="property"></em><span class="sig-name descname">notchTarget⁼</span><em class="property"><span class="p">:</span><span class="w"> </span><span class="pre">float</span></em><a class="headerlink" href="#PySide6.QtWidgets.QDial.notchTarget" title="Link to this definition">#</a></dt> <dd></dd></dl> <p>此属性包含凹口之间像素的目标数量。</p> <p>凹口目标是QString attempts to put between each notch.</p> <p>实际大小可能与目标大小不同。</p> <p>默认凹口目标为3.7像素。</p> <dl class="simple"> <dt><strong>访问函数</strong></dt><dd><ul class="simple"> <li><p><a class="reference internal" href="#id1" title="PySide6.QtWidgets.QDial.notchTarget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">notchTarget()</span></code></a></p></li> <li><p><a class="reference internal" href="#PySide6.QtWidgets.QDial.setNotchTarget" title="PySide6.QtWidgets.QDial.setNotchTarget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setNotchTarget()</span></code></a></p></li> </ul> </dd> </dl> <dl class="py property"> <dt class="sig sig-object py" id="PySide6.QtWidgets.QDial.notchesVisible"> <em class="property">属性</em><em class="property"></em><span class="sig-name descname">notchesVisible⁼</span><em class="property"><span class="p">:</span><span class="w"> </span><span class="pre">bool</span></em><a class="headerlink" href="#PySide6.QtWidgets.QDial.notchesVisible" title="Link to this definition">#</a></dt> <dd></dd></dl> <p>此属性包含是否显示凹口。</p> <p>如果属性为<code class="docutils literal notranslate">true</code>,则在转盘周围绘制一系列凹口以表示可用的值范围;否则不显示凹口。</p> <p>默认情况下,此属性是禁用的。</p> <dl class="simple"> <dt><strong>访问函数</strong></dt><dd><ul class="simple"> <li><p><a class="reference internal" href="#id2" title="PySide6.QtWidgets.QDial.notchesVisible"><code class="xref py py-meth docutils literal notranslate"><span class="pre">notchesVisible()</span></code></a></p></li> <li><p><a class="reference internal" href="#PySide6.QtWidgets.QDial.setNotchesVisible" title="PySide6.QtWidgets.QDial.setNotchesVisible"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setNotchesVisible()</span></code></a></p></li> </ul> </dd> </dl> <dl class="py property"> <dt class="sig sig-object py" id="PySide6.QtWidgets.QDial.wrapping"> <em class="property">属性</em><em class="property"></em><span class="sig-name descname">wrapping⁼</span><em class="property"><span class="p">:</span><span class="w"> </span><span class="pre">bool</span></em><a class="headerlink" href="#PySide6.QtWidgets.QDial.wrapping" title="Link to this definition">#</a></dt> <dd></dd></dl> <p>此属性包含是否启用循环。</p> <p>如果为true,则启用循环;否则在转盘底部插入一些空间,以分隔有效值范围的端点。</p> <p>如果启用,箭头可以在转盘上的任何角度定位。如果禁用,箭头将限制在转盘的上部;如果将其旋转到底部空间中,则将其夹到最接近的有效值范围端点。</p> <p>默认情况下此属性为<code class="docutils literal notranslate">false</code>。</p> <dl class="simple"> <dt><strong>访问函数</strong></dt><dd><ul class="simple"> <li><p><a class="reference internal" href="#id3" title="PySide6.QtWidgets.QDial.wrapping"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wrapping()</span></code></a></p></li> <li><p><a class="reference internal" href="#PySide6.QtWidgets.QDial.setWrapping" title="PySide6.QtWidgets.QDial.setWrapping"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setWrapping()</span></code></a></p></li> </ul> </dd> </dl> <dl class="py method"> <dt class="sig sig-object py" id="PySide6.QtWidgets.QDial.__init__"> <span class="sig-name descname">__init__</span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">parent=None</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#PySide6.QtWidgets.QDial.__init__" title="Link to this definition">#</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">参数:</dt> <dd class="field-odd"><p><strong>parent</strong> - <a class="reference internal" href="QWidget.html#PySide6.QtWidgets.QWidget" title="PySide6.QtWidgets.QWidget"><code class="xref py py-class docutils literal notranslate">QWidget</code></a></p> </dd> </dl> </dd></dl> <p>构建一个转盘。</p> <p><code class="docutils literal notranslate">parent</code>参数传递给<code class="xref py py-class docutils literal notranslate">QAbstractSlider</code>构造函数。</p> <dl class="py method"> <dt class="sig sig-object py" id="PySide6.QtWidgets.QDial.initStyleOption"> <span class="sig-name descname">initStyleOption</span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">option</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PySide6.QtWidgets.QDial.initStyleOption" title="Link to this definition">#</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">参数:</dt> <dd class="field-odd"><p><strong>选项</strong> – <a class="reference internal" href="QStyleOptionSlider.html#PySide6.QtWidgets.QStyleOptionSlider" title="PySide6.QtWidgets.QStyleOptionSlider"><code class="xref py py-class docutils literal notranslate"><span class="pre">QStyleOptionSlider</span></code></a></p> </dd> </dl> </dd></dl> <p>使用此 <a class="reference internal" href="#PySide6.QtWidgets.QDial" title="PySide6.QtWidgets.QDial"><code class="xref py py-class docutils literal notranslate"><span class="pre">QDial</span></code></a> 的值初始化 <code class="docutils literal notranslate"><span class="pre">option</span></code>。该方法对于子类来说非常有用,当它们需要一个 <a class="reference internal" href="QStyleOptionSlider.html#PySide6.QtWidgets.QStyleOptionSlider" title="PySide6.QtWidgets.QStyleOptionSlider"><code class="xref py py-class docutils literal notranslate"><span class="pre">QStyleOptionSlider</span></code></a> ,但又不想自己填写所有信息时。</p> <blockquote> <div><div class="admonition seealso"> <p class="admonition-title">另请参阅</p> <p><a class="reference internal" href="QStyleOption.html#PySide6.QtWidgets.QStyleOption.initFrom" title="PySide6.QtWidgets.QStyleOption.initFrom"><code class="xref py py-meth docutils literal notranslate"><span class="pre">initFrom()</span></code></a></p> </div> </div></blockquote> <dl class="py method"> <dt class="sig sig-object py" id="id0"> <span class="sig-name descname"><span class="pre">notchSize</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#id0" title="Link to this definition">#</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">返回类型<span class="colon">:</span></dt> <dd class="field-odd"><p>int</p> </dd> </dl> </dd></dl> <p>属性 <a class="reference internal" href="#PySide6.QtWidgets.QDial.notchSize" title="PySide6.QtWidgets.QDial.notchSizeᅟ"><code class="xref py py-attr docutils literal notranslate"><span class="pre">notchSizeᅟ</span></code></a> 的获取器。</p> <dl class="py method"> <dt class="sig sig-object py" id="id1"> <span class="sig-name descname"><span class="pre">notchTarget</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#id1" title="Link to this definition">#</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">返回类型<span class="colon">:</span></dt> <dd class="field-odd"><p>float</p> </dd> </dl> <div class="admonition seealso"> <p class="admonition-title">另请参阅</p> <p><a class="reference internal" href="#PySide6.QtWidgets.QDial.setNotchTarget" title="PySide6.QtWidgets.QDial.setNotchTarget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setNotchTarget()</span></code></a></p> </div> </dd></dl> <p>属性 <a class="reference internal" href="#PySide6.QtWidgets.QDial.notchTarget" title="PySide6.QtWidgets.QDial.notchTargetᅟ"><code class="xref py py-attr docutils literal notranslate"><span class="pre">notchTargetᅟ</span></code></a> 的获取器。</p> <dl class="py method"> <dt class="sig sig-object py" id="id2"> <span class="sig-name descname"><span class="pre">notchesVisible</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#id2" title="Link to this definition">#</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">返回类型<span class="colon">:</span></dt> <dd class="field-odd"><p>bool</p> </dd> </dl> <div class="admonition seealso"> <p class="admonition-title">另请参阅</p> <p><a class="reference internal" href="#PySide6.QtWidgets.QDial.setNotchesVisible" title="PySide6.QtWidgets.QDial.setNotchesVisible"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setNotchesVisible()</span></code></a></p> </div> </dd></dl> <p>属性 <a class="reference internal" href="#PySide6.QtWidgets.QDial.notchesVisible" title="PySide6.QtWidgets.QDial.notchesVisibleᅟ"><code class="xref py py-attr docutils literal notranslate"><span class="pre">notchesVisibleᅟ</span></code></a> 的获取器。</p> <dl class="py method"> <dt class="sig sig-object py" id="PySide6.QtWidgets.QDial.setNotchTarget"> <span class="sig-name descname"><span class="pre">setNotchTarget</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PySide6.QtWidgets.QDial.setNotchTarget" title="Link to this definition">#</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">参数:</dt> <dd class="field-odd"><p><strong>target</strong> – float</p> </dd> </dl> <div class="admonition seealso"> <p class="admonition-title">另请参阅</p> <p><a class="reference internal" href="#id1" title="PySide6.QtWidgets.QDial.notchTarget"><code class="xref py py-meth docutils literal notranslate"><span class="pre">notchTarget()</span></code></a></p> </div> </dd></dl> <dl class="py method"> <dt class="sig sig-object py" id="PySide6.QtWidgets.QDial.setNotchesVisible"> <span class="sig-name descname"><span class="pre">setNotchesVisible</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">visible</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PySide6.QtWidgets.QDial.setNotchesVisible" title="Link to this definition">#</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">参数:</dt> <dd class="field-odd"><p><strong>visible</strong> – bool</p> </dd> </dl> <div class="admonition seealso"> <p class="admonition-title">另请参阅</p> <p><a class="reference internal" href="#id2" title="PySide6.QtWidgets.QDial.notchesVisible"><code class="xref py py-meth docutils literal notranslate"><span class="pre">notchesVisible()</span></code></a></p> </div> </dd></dl> <p>属性 <a class="reference internal" href="#PySide6.QtWidgets.QDial.notchesVisible" title="PySide6.QtWidgets.QDial.notchesVisibleᅟ"><code class="xref py py-attr docutils literal notranslate"><span class="pre">notchesVisibleᅟ</span></code></a> 的设置器。</p> <dl class="py method"> <dt class="sig sig-object py" id="PySide6.QtWidgets.QDial.setWrapping"> <span class="sig-name descname"><span class="pre">setWrapping</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">on</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#PySide6.QtWidgets.QDial.setWrapping" title="Link to this definition">#</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">参数:</dt> <dd class="field-odd"><p><strong>on</strong> – bool</p> </dd> </dl> <div class="admonition seealso"> <p class="admonition-title">另请参阅</p> <p><a class="reference internal" href="#id3" title="PySide6.QtWidgets.QDial.wrapping"><code class="xref py py-meth docutils literal notranslate"><span class="pre">wrapping()</span></code></a></p> </div> </dd></dl> <p>属性 <a class="reference internal" href="#PySide6.QtWidgets.QDial.wrapping" title="PySide6.QtWidgets.QDial.wrappingᅟ"><code class="xref py py-attr docutils literal notranslate"><span class="pre">wrappingᅟ</span></code></a> 的设置器。</p> <dl class="py method"> <dt class="sig sig-object py" id="id3"> <span class="sig-name descname"><span class="pre">wrapping</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#id3" title="Link to this definition">#</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">返回类型<span class="colon">:</span></dt> <dd class="field-odd"><p>bool</p> </dd> </dl> <div class="admonition seealso"> <p class="admonition-title">另请参阅</p> <p><a class="reference internal" href="#PySide6.QtWidgets.QDial.setWrapping" title="PySide6.QtWidgets.QDial.setWrapping"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setWrapping()</span></code></a></p> </div> </dd></dl> <p>属性 <a class="reference internal" href="#PySide6.QtWidgets.QDial.wrapping" title="PySide6.QtWidgets.QDial.wrappingᅟ"><code class="xref py py-attr docutils literal notranslate"><span class="pre">wrappingᅟ</span></code></a> 的获取器。</p> </section> </dd></dl> </article> </div> <footer> <div class="related-pages"> <a class="next-page" href="QDialog.html"> <div class="page-info"> <div class="context"> <span>Next</span> </div> <div class="title">Synopsis</div> </div> <svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg> </a> <a class="prev-page" href="QDateTimeEdit.html"> <svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg> <div class="page-info"> <div class="context"> <span>Previous</span> </div> <div class="title">Synopsis</div> </div> </a></div> <div class="bottom-of-page"> <div class="left-details"> <div class="copyright">版权所有 © 2024 Qt Company Ltd。本文件包含的文档贡献者是各自版权所有者。本文件提供的文档是根据自由软件基金会发布的GNU自由文档许可版1.3(https://www.gnu.org/licenses/fdl.html)许可的。Qt及其相关商标是Qt Company Ltd.在芬兰及全球其他国家的商标。所有其他商标均为各自所有者的财产。</div>由<a href="https://sphinx-doc.cn/">Sphinx</a>和<a class="muted-link" href="https://pradyunsg.me">@pradyunsg</a>的<a href="https://github.com/pradyunsg/furo">Furo</a>制作</div> <div class="right-details"> </div> </div> </footer> </div> <aside class="toc-drawer"> <div class="toc-sticky toc-scroll"> <div class="toc-title-container"> <span class="toc-title">本页内容</span> </div> <div class="toc-tree-container"> <div class="toc-tree"> <ul> <li><a class="reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">QDial</span></code></a><ul> <li><a class="reference internal" href="#PySide6.QtWidgets.QDial.notchSize"><code class="docutils literal notranslate"><span class="pre">QDial.notchSize</span></code></a></li> <li><a class="reference internal" href="#PySide6.QtWidgets.QDial.notchTarget"><code class="docutils literal notranslate"><span class="pre">QDial.notchTarget</span></code></a></li> <li><a class="reference internal" href="#PySide6.QtWidgets.QDial.notchesVisible"><code class="docutils literal notranslate"><span class="pre">QDial.notchesVisible</span></code></a></li> <li><a class="reference internal" href="#PySide6.QtWidgets.QDial.wrapping"><code class="docutils literal notranslate"><span class="pre">QDial.wrapping</span></code></a></li> <li><a class="reference internal" href="#PySide6.QtWidgets.QDial.__init__"><code class="docutils literal notranslate"><span class="pre">QDial.__init__()</span></code></a></li> <li><a class="reference internal" href="#PySide6.QtWidgets.QDial.initStyleOption"><code class="docutils literal notranslate"><span class="pre">QDial.initStyleOption()</span></code></a></li> <li><a class="reference internal" href="#id0"><code class="docutils literal notranslate"><span class="pre">QDial.notchSize()</span></code></a></li> <li><a class="reference internal" href="#id1"><code class="docutils literal notranslate"><span class="pre">QDial.notchTarget()</span></code></a></li> <li><a class="reference internal" href="#id2"><code class="docutils literal notranslate"><span class="pre">QDial.notchesVisible()</span></code></a></li> <li><a class="reference internal" href="#PySide6.QtWidgets.QDial.setNotchTarget"><code class="docutils literal notranslate"><span class="pre">QDial.setNotchTarget()</span></code></a></li> <li><a class="reference internal" href="#PySide6.QtWidgets.QDial.setNotchesVisible"><code class="docutils literal notranslate"><span class="pre">QDial.setNotchesVisible()</span></code></a></li> <li><a class="reference internal" href="#PySide6.QtWidgets.QDial.setWrapping"><code class="docutils literal notranslate"><span class="pre">QDial.setWrapping()</span></code></a></li> <li><a class="reference internal" href="#id3"><code class="docutils literal notranslate"><span class="pre">QDial.wrapping()</span></code></a></li> </ul> </li> </ul> </div> </div> </div> </aside> </div> </div><script src="../../_static/documentation_options.js?v=f5b8fa4c"></script> <script src="../../_static/doctools.js?v=888ff710"></script> <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script> <script src="../../_static/scripts/furo.js?v=32e29ea5"></script> <script src="../../_static/clipboard.min.js?v=a7894cd8"></script> <script src="../../_static/copybutton.js?v=f281be69"></script> <script src="../../_static/design-tabs.js?v=36754332"></script> <script src="/scripts/pyside-vselect.js"></script> </body></html>