[Interest] widget rendering (alignment, sizing) issues on OS X

Adam Light aclight at gmail.com
Wed May 25 15:28:27 CEST 2016


On Tue, May 24, 2016 at 11:40 AM, René J. V. <rjvbertin at gmail.com> wrote:

> René J.V. Bertin wrote:
>
> I think I posted the question below to the wrong list.
>
> Has anyone ever noticed widgets not being aligned correctly because of
> sizing
> issues on OS X, outside of KDE applications, as shown in the link below?
> https://bugs.kde.org/show_bug.cgi?id=363423
>
> I've dug around some more on this and had some feedback which led me to
> understand that this happens when widgets are used that somehow do not use
> QMacStyle but QStyle instead.
>
> The fixes I found are extremely simple, requiring only the
> Qt::WA_LayoutUsesWidgetRect attribute to be set on the widget in question:
>

In our application, we have the following code in a
QApplication::eventFilter reimplementation for this exact reason:

		case QEvent::ChildAdded:

			{

				QChildEvent* childEvent = static_cast<QChildEvent*>(event);

				if (childEvent->child()->isWidgetType()) {

					QWidget* theChildWidget = qobject_cast<QWidget*>(childEvent->child());

					theChildWidget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);

				}

			}

			break;


We do this on Macintosh and Windows. Testing I did years ago did not show
any effect on Windows, but without doing this on Macintosh the layouts of
many of our dialogs do not look very good. The attribute probably doesn't
actually need to be set on every widget type, but I didn't notice much harm
in doing so.

I believe that if you set a style sheet on a widget, then it's style will
no longer be/derive from QMacStyle on Macintosh. So one solution might be
not using QWidget::setStyleSheet. But that may not be sufficient to remove
the need for the WA_LayoutUsesWidgetRect attribute.

Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160525/e389694f/attachment.html>


More information about the Interest mailing list