What just happened?

The implicitWidth and implicitHeight properties can contain the desired size the item wants to have. It's a direct equivalent of sizeHint() from Qt Widgets. By using these two properties instead of width and height (which are bound to implicitWidth and implicitHeight by default), we allow the user of our component to override those implicit values. When this happens and the user does not set the width or height big enough to contain the icon and text of the button, we prevent the content from crossing the boundaries of the parent item by setting the clip property to true.

Clipping can reduce performance of your game, so use it only when necessary.

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.