[Interest] Issue with qt_qpa_set_cursor with native widget

sivan nanthiran nanthiran2005 at gmail.com
Fri Apr 14 03:31:22 CEST 2023


Hi,

I have a test app that has a native widget and a QLabel arranged in a
horizontal layout side by side. The application's attribute of
Qt::AA_DontCreateNativeWidgetSiblings is set to true. A cursor is set to
QLabel as following,
label->setCursor(QCursor(Qt::SizeHorCursor));

In the mousePressEvent of native widget, I emit a signal which is connected
to enable or disable the QLabel beside it. What I notice is that the cursor
immediately changes to the SizeHorCursor although the mouse is still on my
native widget. And the code of qt_qpa_set_cursor does confirm why that is
happening. However, I don't understand why is it doing it without even
checking if the mouse is on the widget

The below piece of code in qt_qpa_set_cursor is the reason why its
happening.
w = QLabel, and its internalWinId() == 0, so the nativeParent will become
the top most widget.

And since w->testAttribute(Qt::WA_SetCursor) is true, it just change the
cursor of the nativeParent
QWidget *nativeParent = w;
if (!w->internalWinId())
nativeParent = w->nativeParentWidget();
if (!nativeParent || !nativeParent->internalWinId())
return;

if (w->isWindow() || w->testAttribute(Qt::WA_SetCursor)) {
if (w->isEnabled())
applyCursor(nativeParent, w->cursor());
Thanks in advance.

Regards,
Sivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230414/9112c2fb/attachment.htm>


More information about the Interest mailing list