Qt Labs Controls cusomization
-
I want change button shape to circle, when i trying to set radius by
Button { text: "Click me!" background.radius: width/2 }
Engine gives error message: Cannot assign to non-existent property "radius"
But it works when i set in onCompleted:
Component.onCompleted { background.radius = width/2 }
I guess that because at run-time background type change from Item to Rectangle. So, whats the proper way to modify control appearance?
-
QML property binding vs. JS expression. The former needs a well-defined type whereas the latter is resolved dynamically.
The background can be any item. Whilst one style might use a rectangle, another style might use an image instead. Therefore we don't make any assumptions on the exact type in the API.
The way the controls have been designed is that if one is not happy with the default visuals, one can replace basically any part of any control. Or implement the whole template if desired. The default implementation is actually even included in the docs to be used as a starting point.
As for circular buttons, the idea of adding yet another button type has been float^^^circulating around. It's not entirely out of question that we'd provide such type out of the box in the future. Filing in suggestions to bugreports.qt.io is the best way to influence. ;)
-
@jpnurmi said:
The way the controls have been designed is that if one is not happy with the default visuals, one can replace basically any part of any control. Or implement the whole template if desired. The default implementation is actually even included in the docs to be used as a starting point.
But in case when user need to change one/two properties: copy-pasting whole background Rectangle part from module with editing is kind of weird thing which brings issues. Currently I see only one way to do that - use indirect bindings via Binding type.
@jpnurmi, by the way, what difference between dev and 5.7 branches, is it possible to use dev or 5.7 with Qt 5.6?
-
@morte said:
But in case when user need to change one/two properties: copy-pasting whole background Rectangle part from module with editing is kind of weird thing which brings issues.
Yes, it’s unfortunate that we can’t provide simple properties for customizing everything. After carefully analyzing what happened with Qt Quick Controls 1.x, we have made a conscious choice to keep things simple and avoid creating large amounts of styling related bindings. Even though a single binding doesn’t cost that much, it all adds up. Once we go that route, there’s no end to it. More and more styling attributes would be added until it becomes so heavy that it no longer runs on low-end hardware, again. Been there, done that. :) Therefore, now we provide simple style-specific theming mechanisms to change accent colors and such, and then expose the building blocks so that they can be entirely replaced when the default implementation is not satisfactory. We have a change in the pipeline that will setup the style name as a built-in file selector to make style-specific tweaks convenient.
@jpnurmi, by the way, what difference between dev and 5.7 branches, is it possible to use dev or 5.7 with Qt 5.6?
Qt 5.6 is just about to be released, so we haven’t been pushing any new features there anymore. We might push a fix or two to the upcoming 5.6.x patch releases, but we’ll be mostly focusing on getting the first official release in shape in the 5.7 branch. Normally all new features would be pushed to the dev branch. The 5.7 branch is already feature frozen and supposed to gain only stabilizing bug fixes, but tech preview modules have an exemption to continue the development a bit longer. Unfortunately, we can’t give any promise that the controls in 5.7 would stay compatible with the rest of Qt 5.6. It happens quite often that we have to change some internals in the modules we depend on, and then the controls will not necessary build with 5.6 anymore.