当前位置:网站首页>QML control type: tooltip
QML control type: tooltip
2022-07-01 01:51:00 【Friendly, friend】
One 、 describe
ToolTip Inherited from Popup, You can provide tooltips for any control . A tooltip is a short piece of text that informs the user of the control's functionality . It is usually placed above or below the parent control . The prompt text can be any rich text string .

1.1、 Additional tooltips
The most direct way to set tooltips for controls is to specify text and visibility through additional properties .
Button {
text: qsTr("Save")
ToolTip.visible: down
ToolTip.text: qsTr("Save the active project")
}
1.2、 Delays and timeouts
Tooltips are usually displayed due to an external event or user interaction , And they are usually hidden after a timeout .
The following example demonstrates how to delay the display of tooltips , And once the button is released , Tooltips will be hidden :
Button {
text: qsTr("Button")
ToolTip.visible: pressed
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.text: qsTr("This tool tip is shown after pressing and holding the button down.")
}
The following example shows how to display a tooltip after hovering a button for one second , And hide it after five seconds :
import QtQuick
import QtQuick.Controls
Window
{
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Button
{
text: qsTr("Button")
hoverEnabled: true
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.visible: hovered
ToolTip.text: qsTr(" This tooltip appears after hovering the button for one second ")
}
}
1.3、 Custom tool tips
The following example provides a tooltip , The tooltip displays the value of the slider as you drag the handle :
Slider
{
id: slider
value: 0.5
width: 150
ToolTip {
parent: slider.handle
visible: slider.pressed
text: slider.value.toFixed(1)
}
}
Two 、 Customize ToolTip Example
import QtQuick
import QtQuick.Controls
Window
{
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Button
{
id:btn
text: qsTr("Button")
hoverEnabled: true
ToolTip {
id: control
text: qsTr("A descriptive tool tip of what the button does")
delay: 1000
timeout: 5000
visible: btn.hovered
contentItem: Text {
text: control.text
font: control.font
color: "#21be2b"
}
background: Rectangle {
border.color: "#129bf1"
}
}
}
}
3、 ... and 、 Attribute members
1、delay : int
Delay in displaying tooltips ( millisecond ). The default value is 0. Set less than 0 Also for the 0.
2、text : string
The text displayed on the tooltip .
3、timeout : int
Timeout after tooltip hiding ( millisecond ). Negative numbers do not automatically hide tooltips . The default value is -1.
Four 、 Additional attribute members
1、ToolTip.delay : int、ToolTip.text : string、ToolTip.timeout : int
Same attribute member .
2、ToolTip.toolTip : ToolTip
Share tooltip instances . This attribute can be attached to any item .
3、ToolTip.visible : bool
Whether the shared tooltip is visible . This attribute can be attached to any item .
5、 ... and 、 Member functions
1、void hide()
Hide tooltips .
2、void show(string text, int timeout)
Display as a tooltip , The timeout is timeout millisecond .
6、 ... and 、 Additional member functions
1、void hide()
Hide shared tooltips . This method can be attached to any project .
2、void show(string text, int timeout = -1)
Display with text and timeout timeout Millisecond shared tooltip . This method can be attached to any project .
边栏推荐
- 对象与对象变量
- Institute of Microbiology, commonly used biochemical reactions in microbiological testing
- Laravel+redis generates an order number - automatically increase from 1 on the same day
- Sort custom function
- AS400 entretien d'usine
- System. Csrebot for commandline
- Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
- Log4j2 threadcontext log link tracking
- Mathematical knowledge: finding combinatorial number IV - finding combinatorial number
- Electron pit Addon
猜你喜欢

Selenium classic interview question - multi window switching solution

Upstream and downstream in software development

(翻译)实时内联验证更容易让用户犯错的原因
2022年最新csdn涨薪技术栈-app自动化测试概述

Understanding and application of Qt5 layout in creation

(翻译)使用眉状文本提高标题点击率

小程序中实现excel数据的批量导入
![[fundamentals of wireless communication-14]: illustrated mobile communication technology and application development-2-the first generation mobile analog communication big brother](/img/fa/f9bad44147ba9af21183b7bd630e32.png)
[fundamentals of wireless communication-14]: illustrated mobile communication technology and application development-2-the first generation mobile analog communication big brother

New opportunities for vr/ar brought by metauniverse

Short message sending solution in medical his industry
随机推荐
FL Studio20.9水果软件高级中文版电音编曲
New opportunities for vr/ar brought by metauniverse
Electron pit Addon
AS400 entretien d'usine
Last day of the second quarter
Log4j2 ThreadContext日志链路追踪
go导入自建包
What other hot spots are hidden under 1500W playback? Station B 2 future trends you can't miss
Compile and install oh my Zsh
What are the functions of soil microorganisms in microbial detection?
[无线通信基础-14]:图解移动通信技术与应用发展-2-第一代移动模拟通信大哥大
对象与对象变量
[proteus simulation] Arduino UNO +74c922 keyboard decoding drive 4x4 matrix keyboard
视频教程 | 长安链推出系列视频教程合集(入门)
1500w播放下还藏着什么热点?B站2个未来趋势你不得错过
物业怎么发短信通知给业主?
[fundamentals of wireless communication-14]: illustrated mobile communication technology and application development-2-the first generation mobile analog communication big brother
Microbial safety and health, what is biological treatment?
Ks009 implementation of pet management system based on SSH
直播商城源码,实现左右联动商品分类页面