[Development] Qt Quick Controls 2.0

Nurmi J-P jpnurmi at theqtcompany.com
Mon May 25 11:03:50 CEST 2015


> On 25 May 2015, at 08:56, manish sharma <83.manish at gmail.com> wrote:
> 
> Hi,
> 
> I was reading https://blog.qt.io/blog/2015/03/31/qt-quick-controls-for-embedded/ and it looks very promising.
> 
> Currently I am using QtQuickControls 1.3 and I am customizing look and feel by extending QtQuick.Controls.Styles.
> 
> I just browsed through qtquickcontrols2 code and i could not find Style hooks. Is it by design Or something which is coming up?

Hi Manish,

This is what the “styles” section in the blog post talks about:

> The concept of styling is changing in a way that styles no longer provide components
> that are dynamically instantiated by controls, but controls themselves consist of delegates
> that can be replaced without dynamic instantiation.

In fact, any visual part of any control can be replaced by your own. Here’s an example of a Button with a custom background. The background is a simplified version Qt Quick Controls 1 Base style’s Button background.

         Button {
            id: control
            text: "Button"
            Theme.selectedTextColor: "black" // WIP! This will change...
            background: Rectangle {
                radius: 3
                border.color: control.activeFocus ? "#47b" : "#999"
                gradient: Gradient {
                    GradientStop { color: control.pressed ? "#aaa" : "#fefefe"; position: 0 }
                    GradientStop { color: control.pressed ? "#ccc" : "#e3e3e3"; position: control.pressed ? 0.1 : 1 }
                }
                Rectangle {
                    radius: 3
                    anchors.fill: parent
                    color: control.activeFocus ? "#194477bb" : "transparent"
                    Behavior on color { ColorAnimation { duration: 100 } }
                }
            }
        }

Disclaimer: these things are still heavily work in progress.

--
J-P Nurmi




More information about the Development mailing list