QML:保持滑块上的工具提示始终可见

huangapple go评论61阅读模式
英文:

QML: keep tooltip visible all the time on the slider

问题

我有一个页面,其中包含几个按钮和一个滑块。这个页面通过一个加载器动态加载,加载器的焦点设置为true。我按照这个文档自定义滑块来自定义滑块。

我已经附加了一个工具提示到工具提示的手柄,基本上是给定的矩形作为手柄。我将工具提示的可见属性设置为true,以使其始终可见,超时设置为-1。根据我的要求,这个工具提示应该始终对用户可见,即使他正在与页面上的其他控件进行交互,比如按钮。

但是,尽管我将可见属性设置为true,在单击滑块外部或与按钮交互时,工具提示会消失。我还尝试删除“超时”属性,但它的默认值已经是-1,所以在代码中保留或不保留它是没有意义的。

我还尝试使用加载器和包含此滑块的页面的焦点属性,使其可见,但它只对键盘焦点起作用,这不是我所需要的。我尝试使用MouseArea和其按下事件处理来使工具提示可见,但不起作用。

为什么工具提示的可见属性在设置为true时不起作用,或者不能使其始终可见?基本上,单击滑块外部会失去对它的焦点,这是我理解的原因。

提前感谢您的帮助。

英文:

I have a page, containing few buttons and a slider. This page getting dynamically loaded through a loader, which has focus set true. I did customization of slider by following this doc customizing slider

I have attached a tooltip with the Handle of tooltip, basically with given rectangle as handle.
I set tooltip visible property true to make it visible all the time and timeout -1. As per my requirement this tooltip should always visible to user, even though he is interacting with other controls, like button on the same page.
But even though I kept visible property set true, on clicking outside of the slider or interaction with buttons, make tooltip disappear. I also tried with removing "timeout" property, but its default value already -1. So make no sense of keeping or not keeping it in the code.
I also tried that focus property of loader and the page in which this slider reside, to make it visible but its only work with keyboard focus, which I don't required. I tried with MouseArea and its press event handling, to make tooltip visible, but not working.
Why tooltip visible property is not working or making it visible all the time, when it get set true? Basically clicking outside of slider, lose the focus from it, that what I understand.

Thanks in advance for helping out here.

答案1

得分: 2

我不确定您想要的行为具体是什么,但您可以尝试这个属性:

closePolicy: Popup.NoAutoClose

您可以在这里查看其他选项:链接

英文:

I'm not sure exactly what behavior you want, but you might try this property:

closePolicy: Popup.NoAutoClose

You can look at the other options here

huangapple
  • 本文由 发表于 2023年7月3日 23:01:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76605941.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定