Skip to content

Draft: qt/qml: implement custom attached ToolTip

Fatih Uzunoğlu requested to merge fuzun/vlc:qml-custom-tooltip-2 into master

In various places, Qt Quick ToolTip is used. However, the default attached ToolTip should not be used because it does not adhere to the custom theme. At the same time, we still want to use attached ToolTip because it is handier than explicitly creating a child ToolTip.

The solution I propose is to create a custom ToolTip type on the Qml side, and create a ToolTipAttached class as a wrapper to use the created custom ToolTip instead of default ToolTip and override attached property "ToolTip" to use AttachedToolTip instead of QQuickToolTipAttached.

ToolTipAttached class is obviously ported from QQuickToolTipAttached. Unfortunately, because both QQuickToolTip and QQuickToolTipAttached are private classes, it was required to do that. If access to private Qt classes is allowed, I can do the required changes. @chub, let me know if there is a license problem.

Because QQuickToolTip inherits another private class QQuickPopup, I used Qt Meta Object system in order to access properties and invoke methods. This should not cause any problem as long as Qt API does not change. I tested on 5.11.3, but it should be fine at least up to 5.15.2.

If overriding attached ToolTip is not wanted, I can change it's name. However, this will also require more changes on the qml side to migrate from the old name to the new name. I believe overriding should be fine if I don't miss something.

Merge request reports